{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="float-right">
        <button type="submit" form="form-product" formaction="{{ action }}" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fas fa-save"></i></button>
        <a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-light"><i class="fas fa-reply"></i></a></div>
      <h1>{{ heading_title }}</h1>
      <ol class="breadcrumb">
        {% for breadcrumb in breadcrumbs %}
          <li class="breadcrumb-item"><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
        {% endfor %}
      </ol>
    </div>
  </div>
  <div class="container-fluid">
    {% if error_warning %}
      <div class="alert alert-danger alert-dismissible"><i class="fas fa-exclamation-circle"></i> {{ error_warning }}
        <button type="button" class="close" data-dismiss="alert">&times;</button>
      </div>
    {% endif %}
    <div class="card">
      <div class="card-header"><i class="fas fa-pencil-alt"></i> {{ text_form }}</div>
      <div class="card-body">
        {% if master_id %}
          <div class="alert alert-warning"><i class="fas fa-exclamation-circle"></i> {{ text_variant }}</div>
        {% endif %}
        <form method="post" enctype="multipart/form-data" id="form-product">
          <ul class="nav nav-tabs">
            <li class="nav-item"><a href="#tab-general" data-toggle="tab" class="nav-link active">{{ tab_general }}</a></li>
            <li class="nav-item"><a href="#tab-data" data-toggle="tab" class="nav-link">{{ tab_data }}</a></li>
            <li class="nav-item"><a href="#tab-links" data-toggle="tab" class="nav-link">{{ tab_links }}</a></li>
            <li class="nav-item"><a href="#tab-attribute" data-toggle="tab" class="nav-link">{{ tab_attribute }}</a></li>
            <li class="nav-item"><a href="#tab-option" data-toggle="tab" class="nav-link">{{ tab_option }}</a></li>
            <li class="nav-item"><a href="#tab-recurring" data-toggle="tab" class="nav-link">{{ tab_recurring }}</a></li>
            <li class="nav-item"><a href="#tab-discount" data-toggle="tab" class="nav-link">{{ tab_discount }}</a></li>
            <li class="nav-item"><a href="#tab-special" data-toggle="tab" class="nav-link">{{ tab_special }}</a></li>
            <li class="nav-item"><a href="#tab-image" data-toggle="tab" class="nav-link">{{ tab_image }}</a></li>
            <li class="nav-item"><a href="#tab-reward" data-toggle="tab" class="nav-link">{{ tab_reward }}</a></li>
            <li class="nav-item"><a href="#tab-seo" data-toggle="tab" class="nav-link">{{ tab_seo }}</a></li>
            <li class="nav-item"><a href="#tab-design" data-toggle="tab" class="nav-link">{{ tab_design }}</a></li>
          </ul>
          <div class="tab-content">
            <div class="tab-pane active" id="tab-general">
              <ul class="nav nav-tabs" id="language">
                {% for language in languages %}
                  <li class="nav-item"><a href="#language{{ language.language_id }}" data-toggle="tab" class="nav-link"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}"/> {{ language.name }}</a></li>
                {% endfor %}
              </ul>
              <div class="tab-content">
                {% for language in languages %}
                  <div class="tab-pane" id="language{{ language.language_id }}">
                    <div class="form-group row required">
                      <label for="input-name{{ language.language_id }}" class="col-sm-2 col-form-label">{{ entry_name }}</label>
                      <div class="col-sm-10">
                        <div class="input-group">
                          <input type="text" name="product_description[{{ language.language_id }}][name]" value="{{ product_description[language.language_id] ? product_description[language.language_id].name }}" placeholder="{{ entry_name }}" id="input-name{{ language.language_id }}" class="form-control"/>
                          {% if master_id %}
                            <div class="input-group-append">
                              <div class="input-group-text">
                                <div class="custom-control custom-switch">
                                  {% if override.product_description[language.language_id].name %}
                                    <input type="checkbox" name="override[product_description][{{ language.language_id }}][name]" value="1" id="input-variant-name{{ language.language_id }}" data-toggle="switch" data-target="#input-name{{ language.language_id }}" class="custom-control-input" checked/>
                                  {% else %}
                                    <input type="checkbox" name="override[product_description][{{ language.language_id }}][name]" value="1" id="input-variant-name{{ language.language_id }}" data-toggle="switch" data-target="#input-name{{ language.language_id }}" class="custom-control-input"/>
                                  {% endif %}
                                  <label for="input-variant-name{{ language.language_id }}" class="custom-control-label"></label>
                                </div>
                              </div>
                            </div>
                          {% endif %}
                        </div>
                        {% if error_name[language.language_id] %}
                          <div class="invalid-tooltip">{{ error_name[language.language_id] }}</div>
                        {% endif %}
                      </div>
                    </div>
                    <div class="form-group row">
                      <label for="input-description{{ language.language_id }}" class="col-sm-2 col-form-label">{{ entry_description }}</label>
                      <div class="col-sm-10">
                        <div class="input-group">
                          <div class="form-control h-100 p-0 border-0 rounded-0">
                            <textarea name="product_description[{{ language.language_id }}][description]" placeholder="{{ entry_description }}" id="input-description{{ language.language_id }}" data-toggle="ckeditor" data-lang="{{ ckeditor }}" class="w-100 position-relative">{{ product_description[language.language_id] ? product_description[language.language_id].description }}</textarea>
                          </div>
                          {% if master_id %}
                            <div class="input-group-append">
                              <div class="input-group-text">
                                <div class="custom-control custom-switch">
                                  {% if override.product_description[language.language_id].description %}
                                    <input type="checkbox" name="override[product_description][{{ language.language_id }}][description]" value="1" id="input-variant-description{{ language.language_id }}" data-toggle="switch" data-target="#input-description{{ language.language_id }}" class="custom-control-input" checked/>
                                  {% else %}
                                    <input type="checkbox" name="override[product_description][{{ language.language_id }}][description]" value="1" id="input-variant-description{{ language.language_id }}" data-toggle="switch" data-target="#input-description{{ language.language_id }}" class="custom-control-input"/>
                                  {% endif %}
                                  <label for="input-variant-description{{ language.language_id }}" class="custom-control-label"></label>
                                </div>
                              </div>
                            </div>
                          {% endif %}
                        </div>
                      </div>
                    </div>
                    <div class="form-group row required">
                      <label for="input-meta-title{{ language.language_id }}" class="col-sm-2 col-form-label">{{ entry_meta_title }}</label>
                      <div class="col-sm-10">
                        <div class="input-group">
                          <input type="text" name="product_description[{{ language.language_id }}][meta_title]" value="{{ product_description[language.language_id] ? product_description[language.language_id].meta_title }}" placeholder="{{ entry_meta_title }}" id="input-meta-title{{ language.language_id }}" class="form-control"/>
                          {% if master_id %}
                            <div class="input-group-append">
                              <div class="input-group-text">
                                <div class="custom-control custom-switch">
                                  {% if override.product_description[language.language_id].meta_title %}
                                    <input type="checkbox" name="override[product_description][{{ language.language_id }}][meta_title]" value="1" id="input-variant-meta-title{{ language.language_id }}" data-toggle="switch" data-target="#input-meta-title{{ language.language_id }}" class="custom-control-input" checked/>
                                  {% else %}
                                    <input type="checkbox" name="override[product_description][{{ language.language_id }}][meta_title]" value="1" id="input-variant-meta-title{{ language.language_id }}" data-toggle="switch" data-target="#input-meta-title{{ language.language_id }}" class="custom-control-input"/>
                                  {% endif %}
                                  <label for="input-variant-meta-title{{ language.language_id }}" class="custom-control-label"></label>
                                </div>
                              </div>
                            </div>
                          {% endif %}
                        </div>
                        {% if error_meta_title[language.language_id] %}
                          <div class="invalid-tooltip">{{ error_meta_title[language.language_id] }}</div>
                        {% endif %}
                      </div>
                    </div>
                    <div class="form-group row">
                      <label for="input-meta-description{{ language.language_id }}" class="col-sm-2 col-form-label">{{ entry_meta_description }}</label>
                      <div class="col-sm-10">
                        <div class="input-group">
                          <textarea name="product_description[{{ language.language_id }}][meta_description]" rows="5" placeholder="{{ entry_meta_description }}" id="input-meta-description{{ language.language_id }}" class="form-control">{{ product_description[language.language_id] ? product_description[language.language_id].meta_description }}</textarea>
                          {% if master_id %}
                            <div class="input-group-append">
                              <div class="input-group-text">
                                <div class="custom-control custom-switch">
                                  {% if override.product_description[language.language_id].meta_description %}
                                    <input type="checkbox" name="override[product_description][{{ language.language_id }}][meta_description]" value="1" id="input-variant-meta-description{{ language.language_id }}" data-toggle="switch" data-target="#input-meta-description{{ language.language_id }}" class="custom-control-input" checked/>
                                  {% else %}
                                    <input type="checkbox" name="override[product_description][{{ language.language_id }}][meta_description]" value="1" id="input-variant-meta-description{{ language.language_id }}" data-toggle="switch" data-target="#input-meta-description{{ language.language_id }}" class="custom-control-input"/>
                                  {% endif %}
                                  <label for="input-variant-meta-description{{ language.language_id }}" class="custom-control-label"></label>
                                </div>
                              </div>
                            </div>
                          {% endif %}
                        </div>
                      </div>
                    </div>
                    <div class="form-group row">
                      <label for="input-meta-keyword{{ language.language_id }}" class="col-sm-2 col-form-label">{{ entry_meta_keyword }}</label>
                      <div class="col-sm-10">
                        <div class="input-group">
                          <textarea name="product_description[{{ language.language_id }}][meta_keyword]" rows="5" placeholder="{{ entry_meta_keyword }}" id="input-meta-keyword{{ language.language_id }}" class="form-control">{{ product_description[language.language_id] ? product_description[language.language_id].meta_keyword }}</textarea>
                          {% if master_id %}
                            <div class="input-group-append">
                              <div class="input-group-text">
                                <div class="custom-control custom-switch">
                                  {% if override.product_description[language.language_id].meta_keyword %}
                                    <input type="checkbox" name="override[product_description][{{ language.language_id }}][meta_keyword]" value="1" id="input-variant-meta-keyword{{ language.language_id }}" data-toggle="switch" data-target="#input-meta-keyword{{ language.language_id }}" class="custom-control-input" checked/>
                                  {% else %}
                                    <input type="checkbox" name="override[product_description][{{ language.language_id }}][meta_keyword]" value="1" id="input-variant-meta-keyword{{ language.language_id }}" data-toggle="switch" data-target="#input-meta-keyword{{ language.language_id }}" class="custom-control-input"/>
                                  {% endif %}
                                  <label for="input-variant-meta-keyword{{ language.language_id }}" class="custom-control-label"></label>
                                </div>
                              </div>
                            </div>
                          {% endif %}
                        </div>
                      </div>
                    </div>
                    <div class="form-group row">
                      <label for="input-tag{{ language.language_id }}" class="col-sm-2 col-form-label">{{ entry_tag }}</label>
                      <div class="col-sm-10">
                        <div class="input-group">
                          <input type="text" name="product_description[{{ language.language_id }}][tag]" value="{{ product_description[language.language_id] ? product_description[language.language_id].tag }}" placeholder="{{ entry_tag }}" id="input-tag{{ language.language_id }}" class="form-control"/>
                          {% if master_id %}
                            <div class="input-group-append">
                              <div class="input-group-text">
                                <div class="custom-control custom-switch">
                                  {% if override.product_description[language.language_id].tag %}
                                    <input type="checkbox" name="override[product_description][{{ language.language_id }}][tag]" value="1" id="input-variant-tag{{ language.language_id }}" data-toggle="switch" data-target="#input-tag{{ language.language_id }}" class="custom-control-input" checked/>
                                  {% else %}
                                    <input type="checkbox" name="override[product_description][{{ language.language_id }}][tag]" value="1" id="input-variant-tag{{ language.language_id }}" data-toggle="switch" data-target="#input-tag{{ language.language_id }}" class="custom-control-input"/>
                                  {% endif %}
                                  <label for="input-variant-tag{{ language.language_id }}" class="custom-control-label"></label>
                                </div>
                              </div>
                            </div>
                          {% endif %}
                        </div>
                        <small class="form-text text-muted">{{ help_tag }}</small>
                      </div>
                    </div>
                  </div>
                {% endfor %}
              </div>
            </div>
            <div id="tab-data" class="tab-pane">
              <input type="hidden" name="master_id" value="{{ master_id }}"/>
              <fieldset>
                <legend>{{ text_model }}</legend>
                <div class="form-group row required">
                  <label for="input-model" class="col-sm-2 col-form-label">{{ entry_model }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <input type="text" name="model" value="{{ model }}" placeholder="{{ entry_model }}" id="input-model" class="form-control"/>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.model %}
                                <input type="checkbox" name="override[model]" value="1" id="input-variant-model" data-toggle="switch" data-target="#input-model" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[model]" value="1" id="input-variant-model" data-toggle="switch" data-target="#input-model" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-model" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                    {% if error_model %}
                      <div class="invalid-tooltip">{{ error_model }}</div>
                    {% endif %}
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-sku" class="col-sm-2 col-form-label">{{ entry_sku }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <input type="text" name="sku" value="{{ sku }}" placeholder="{{ entry_sku }}" id="input-sku" class="form-control"/>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.sku %}
                                <input type="checkbox" name="override[sku]" value="1" id="input-variant-sku" data-toggle="switch" data-target="#input-sku" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[sku]" value="1" id="input-variant-sku" data-toggle="switch" data-target="#input-sku" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-sku" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                    <small class="form-text text-muted">{{ help_sku }}</small>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-upc" class="col-sm-2 col-form-label">{{ entry_upc }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <input type="text" name="upc" value="{{ upc }}" placeholder="{{ entry_upc }}" id="input-upc" class="form-control"/>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.upc %}
                                <input type="checkbox" name="override[upc]" value="1" id="input-variant-upc" data-toggle="switch" data-target="#input-upc" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[upc]" value="1" id="input-variant-upc" data-toggle="switch" data-target="#input-upc" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-upc" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                    <small class="form-text text-muted">{{ help_upc }}</small>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-ean" class="col-sm-2 col-form-label">{{ entry_ean }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <input type="text" name="ean" value="{{ ean }}" placeholder="{{ entry_ean }}" id="input-ean" class="form-control"/>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.ean %}
                                <input type="checkbox" name="override[ean]" value="1" id="input-variant-ean" data-toggle="switch" data-target="#input-ean" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[ean]" value="1" id="input-variant-ean" data-toggle="switch" data-target="#input-ean" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-ean" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                    <small class="form-text text-muted">{{ help_ean }}</small>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-jan" class="col-sm-2 col-form-label">{{ entry_jan }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <input type="text" name="jan" value="{{ jan }}" placeholder="{{ entry_jan }}" id="input-jan" class="form-control"/>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.jan %}
                                <input type="checkbox" name="override[jan]" value="1" id="input-variant-jan" data-toggle="switch" data-target="#input-jan" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[jan]" value="1" id="input-variant-jan" data-toggle="switch" data-target="#input-jan" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-jan" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                    <small class="form-text text-muted">{{ help_jan }}</small>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-isbn" class="col-sm-2 col-form-label">{{ entry_isbn }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <input type="text" name="isbn" value="{{ isbn }}" placeholder="{{ entry_isbn }}" id="input-isbn" class="form-control"/>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.isbn %}
                                <input type="checkbox" name="override[isbn]" value="1" id="input-variant-isbn" data-toggle="switch" data-target="#input-isbn" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[isbn]" value="1" id="input-variant-isbn" data-toggle="switch" data-target="#input-isbn" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-isbn" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                    <small class="form-text text-muted">{{ help_isbn }}</small>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-mpn" class="col-sm-2 col-form-label">{{ entry_mpn }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <input type="text" name="mpn" value="{{ mpn }}" placeholder="{{ entry_mpn }}" id="input-mpn" class="form-control"/>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.mpn %}
                                <input type="checkbox" name="override[mpn]" value="1" id="input-variant-mpn" data-toggle="switch" data-target="#input-mpn" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[mpn]" value="1" id="input-variant-mpn" data-toggle="switch" data-target="#input-mpn" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-mpn" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                    <small class="form-text text-muted">{{ help_mpn }}</small>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-location" class="col-sm-2 col-form-label">{{ entry_location }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <input type="text" name="location" value="{{ location }}" placeholder="{{ entry_location }}" id="input-location" class="form-control"/>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.location %}
                                <input type="checkbox" name="override[location]" value="1" id="input-variant-location" data-toggle="switch" data-target="#input-location" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[location]" value="1" id="input-variant-location" data-toggle="switch" data-target="#input-location" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-location" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                  </div>
                </div>
              </fieldset>
              <fieldset>
                <legend>{{ text_price }}</legend>
                <div class="form-group row">
                  <label for="input-price" class="col-sm-2 col-form-label">{{ entry_price }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <input type="text" name="price" value="{{ price }}" placeholder="{{ entry_price }}" id="input-price" class="form-control"/>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.price %}
                                <input type="checkbox" name="override[price]" value="1" id="input-variant-price" data-toggle="switch" data-target="#input-price" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[price]" value="1" id="input-variant-price" data-toggle="switch" data-target="#input-price" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-price" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-tax-class" class="col-sm-2 col-form-label">{{ entry_tax_class }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <select name="tax_class_id" id="input-tax-class" class="form-control">
                        <option value="0">{{ text_none }}</option>
                        {% for tax_class in tax_classes %}
                          {% if tax_class.tax_class_id == tax_class_id %}
                            <option value="{{ tax_class.tax_class_id }}" selected="selected">{{ tax_class.title }}</option>
                          {% else %}
                            <option value="{{ tax_class.tax_class_id }}">{{ tax_class.title }}</option>
                          {% endif %}
                        {% endfor %}
                      </select>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.tax_class_id %}
                                <input type="checkbox" name="override[tax_class_id]" value="1" id="input-variant-tax-class" data-toggle="switch" data-target="#input-tax-class" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[tax_class_id]" value="1" id="input-variant-tax-class" data-toggle="switch" data-target="#input-tax-class" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-tax-class" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                  </div>
                </div>
              </fieldset>
              <fieldset>
                <legend>{{ text_stock }}</legend>
                <div class="form-group row">
                  <label for="input-quantity" class="col-sm-2 col-form-label">{{ entry_quantity }}</label>
                  <div class="col-sm-10">
                    <input type="text" name="quantity" value="{{ quantity }}" placeholder="{{ entry_quantity }}" id="input-quantity" class="form-control"/>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-minimum" class="col-sm-2 col-form-label">{{ entry_minimum }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <input type="text" name="minimum" value="{{ minimum }}" placeholder="{{ entry_minimum }}" id="input-minimum" class="form-control"/>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.minimum %}
                                <input type="checkbox" name="override[minimum]" value="1" id="input-variant-minimum" data-toggle="switch" data-target="#input-minimum" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[minimum]" value="1" id="input-variant-minimum" data-toggle="switch" data-target="#input-minimum" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-minimum" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                    <small class="form-text text-muted">{{ help_minimum }}</small>
                  </div>
                </div>
                <div class="form-group row">
                  <label class="col-sm-2 col-form-label">{{ entry_subtract }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <div class="btn-group btn-group-toggle" data-toggle="buttons" id="input-subtract">
                        {% if subtract %}
                          <label class="btn btn-outline-secondary active"><input type="radio" name="subtract" value="1" checked="checked"/> {{ text_yes }}</label>
                          <label class="btn btn-outline-secondary"><input type="radio" name="subtract" value="0"/> {{ text_no }}</label>
                        {% else %}
                          <label class="btn btn-outline-secondary"><input type="radio" name="subtract" value="1"/> {{ text_yes }}</label>
                          <label class="btn btn-outline-secondary active"><input type="radio" name="subtract" value="0" checked="checked"/> {{ text_no }}</label>
                        {% endif %}
                      </div>
                      {% if master_id %}
                        <div class="input-group-append align-items-center">
                          <div class="custom-control custom-switch">
                            {% if override.subtract %}
                              <input type="checkbox" name="override[subtract]" value="1" id="input-variant-subtract" data-toggle="switch" data-target="#input-subtract" class="custom-control-input" checked/>
                            {% else %}
                              <input type="checkbox" name="override[subtract]" value="1" id="input-variant-subtract" data-toggle="switch" data-target="#input-subtract" class="custom-control-input"/>
                            {% endif %}
                            <label for="input-variant-subtract" class="custom-control-label"></label>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-stock-status" class="col-sm-2 col-form-label">{{ entry_stock_status }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <select name="stock_status_id" id="input-stock-status" class="form-control">
                        {% for stock_status in stock_statuses %}
                          {% if stock_status.stock_status_id == stock_status_id %}
                            <option value="{{ stock_status.stock_status_id }}" selected="selected">{{ stock_status.name }}</option>
                          {% else %}
                            <option value="{{ stock_status.stock_status_id }}">{{ stock_status.name }}</option>
                          {% endif %}
                        {% endfor %}
                      </select>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.stock_status_id %}
                                <input type="checkbox" name="override[stock_status_id]" value="1" id="input-variant-stock-status" data-toggle="switch" data-target="#input-stock-status" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[stock_status_id]" value="1" id="input-variant-stock-status" data-toggle="switch" data-target="#input-stock-status" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-stock-status" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                    <small class="form-text text-muted">{{ help_stock_status }}</small>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-date-available" class="col-sm-2 col-form-label">{{ entry_date_available }}</label>
                  <div class="col-sm-10 col-md-4">
                    <div class="input-group date">
                      <input type="text" name="date_available" value="{{ date_available }}" placeholder="{{ entry_date_available }}" id="input-date-available" class="form-control"/>
                      <div class="input-group-append">
                        <div class="input-group-text"><i class="fas fa-calendar"></i></div>
                      </div>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.date_available %}
                                <input type="checkbox" name="override[date_available]" value="1" id="input-variant-date-available" data-toggle="switch" data-target="#input-date-available" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[date_available]" value="1" id="input-variant-date-available" data-toggle="switch" data-target="#input-date-available" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-date-available" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                  </div>
                </div>
              </fieldset>
              <fieldset>
                <legend>{{ text_specification }}</legend>
                <div class="form-group row">
                  <label class="col-sm-2 col-form-label">{{ entry_shipping }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <div class="btn-group btn-group-toggle" data-toggle="buttons" id="input-shipping">
                        {% if shipping %}
                          <label class="btn btn-outline-secondary active"><input type="radio" name="shipping" value="1" checked="checked"/> {{ text_yes }}</label>
                          <label class="btn btn-outline-secondary"><input type="radio" name="shipping" value="0"/> {{ text_no }}</label>
                        {% else %}
                          <label class="btn btn-outline-secondary"><input type="radio" name="shipping" value="1"/> {{ text_yes }}</label>
                          <label class="btn btn-outline-secondary active"><input type="radio" name="shipping" value="0" checked="checked"/> {{ text_no }}</label>
                        {% endif %}
                      </div>
                      {% if master_id %}
                        <div class="input-group-append align-items-center">
                          <div class="custom-control custom-switch">
                            {% if override.shipping %}
                              <input type="checkbox" name="override[shipping]" value="1" id="input-variant-shipping" data-toggle="switch" data-target="#input-shipping" class="custom-control-input" checked/>
                            {% else %}
                              <input type="checkbox" name="override[shipping]" value="1" id="input-variant-shipping" data-toggle="switch" data-target="#input-shipping" class="custom-control-input"/>
                            {% endif %}
                            <label for="input-variant-shipping" class="custom-control-label"></label>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-length" class="col-sm-2 col-form-label">{{ entry_dimension }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <input type="text" name="length" value="{{ length }}" placeholder="{{ entry_length }}" id="input-length" class="form-control"/>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.length %}
                                <input type="checkbox" name="override[length]" value="1" id="input-variant-length" data-toggle="switch" data-target="#input-length" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[length]" value="1" id="input-variant-length" data-toggle="switch" data-target="#input-length" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-length" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                      <input type="text" name="width" value="{{ width }}" placeholder="{{ entry_width }}" id="input-width" class="form-control"/>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.width %}
                                <input type="checkbox" name="override[width]" value="1" id="input-variant-width" data-toggle="switch" data-target="#input-width" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[width]" value="1" id="input-variant-width" data-toggle="switch" data-target="#input-width" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-width" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                      <input type="text" name="height" value="{{ height }}" placeholder="{{ entry_height }}" id="input-height" class="form-control"/>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.height %}
                                <input type="checkbox" name="override[height]" value="1" id="input-variant-height" data-toggle="switch" data-target="#input-height" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[height]" value="1" id="input-variant-height" data-toggle="switch" data-target="#input-height" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-height" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-length-class" class="col-sm-2 col-form-label">{{ entry_length_class }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <select name="length_class_id" id="input-length-class" class="form-control">
                        {% for length_class in length_classes %}
                          {% if length_class.length_class_id == length_class_id %}
                            <option value="{{ length_class.length_class_id }}" selected="selected">{{ length_class.title }}</option>
                          {% else %}
                            <option value="{{ length_class.length_class_id }}">{{ length_class.title }}</option>
                          {% endif %}
                        {% endfor %}
                      </select>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.length_class_id %}
                                <input type="checkbox" name="override[length_class_id]" value="1" id="input-variant-length-class" data-toggle="switch" data-target="#input-length-class" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[length_class_id]" value="1" id="input-variant-length-class" data-toggle="switch" data-target="#input-length-class" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-length-class" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-weight" class="col-sm-2 col-form-label">{{ entry_weight }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <input type="text" name="weight" value="{{ weight }}" placeholder="{{ entry_weight }}" id="input-weight" class="form-control"/>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.weight %}
                                <input type="checkbox" name="override[weight]" value="1" id="input-variant-weight" data-toggle="switch" data-target="#input-weight" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[weight]" value="1" id="input-variant-weight" data-toggle="switch" data-target="#input-weight" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-weight" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-weight-class" class="col-sm-2 col-form-label">{{ entry_weight_class }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <select name="weight_class_id" id="input-weight-class" class="form-control">
                        {% for weight_class in weight_classes %}
                          {% if weight_class.weight_class_id == weight_class_id %}
                            <option value="{{ weight_class.weight_class_id }}" selected="selected">{{ weight_class.title }}</option>
                          {% else %}
                            <option value="{{ weight_class.weight_class_id }}">{{ weight_class.title }}</option>
                          {% endif %}
                        {% endfor %}
                      </select>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.weight_class_id %}
                                <input type="checkbox" name="override[weight_class_id]" value="1" id="input-variant-weight-class" data-toggle="switch" data-target="#input-weight-class" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[weight_class_id]" value="1" id="input-variant-weight-class" data-toggle="switch" data-target="#input-weight-class" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-weight-class" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-status" class="col-sm-2 col-form-label">{{ entry_status }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <select name="status" id="input-status" class="form-control">
                        {% if status %}
                          <option value="1" selected="selected">{{ text_enabled }}</option>
                          <option value="0">{{ text_disabled }}</option>
                        {% else %}
                          <option value="1">{{ text_enabled }}</option>
                          <option value="0" selected="selected">{{ text_disabled }}</option>
                        {% endif %}
                      </select>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.status %}
                                <input type="checkbox" name="override[status]" value="1" id="input-variant-status" data-toggle="switch" data-target="#input-status" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[status]" value="1" id="input-variant-status" data-toggle="switch" data-target="#input-status" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-status" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                  </div>
                </div>
                <div class="form-group row">
                  <label for="input-sort-order" class="col-sm-2 col-form-label">{{ entry_sort_order }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <input type="text" name="sort_order" value="{{ sort_order }}" placeholder="{{ entry_sort_order }}" id="input-sort-order" class="form-control"/>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.sort_order %}
                                <input type="checkbox" name="override[sort_order]" value="1" id="input-variant-sort-order" data-toggle="switch" data-target="#input-sort-order" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[sort_order]" value="1" id="input-variant-sort-order" data-toggle="switch" data-target="#input-sort-order" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-sort-order" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                  </div>
                </div>
              </fieldset>
            </div>
            <div id="tab-links" class="tab-pane">
              <div class="form-group row">
                <label class="col-sm-2 col-form-label">{{ entry_manufacturer }}</label>
                <div class="col-sm-10">
                  <div class="input-group">
                    <input type="text" name="manufacturer" value="{{ manufacturer }}" placeholder="{{ entry_manufacturer }}" id="input-manufacturer" class="form-control"/> <input type="hidden" name="manufacturer_id" value="{{ manufacturer_id }}"/>
                    {% if master_id %}
                      <div class="input-group-append">
                        <div class="input-group-text">
                          <div class="custom-control custom-switch">
                            {% if override.manufacturer %}
                              <input type="checkbox" name="override[manufacturer]" value="1" id="input-variant-manufacturer" data-toggle="switch" data-target="#input-manufacturer" class="custom-control-input" checked/>
                            {% else %}
                              <input type="checkbox" name="override[manufacturer]" value="1" id="input-variant-manufacturer" data-toggle="switch" data-target="#input-manufacturer" class="custom-control-input"/>
                            {% endif %}
                            <label for="input-variant-manufacturer" class="custom-control-label"></label>
                          </div>
                        </div>
                      </div>
                    {% endif %}
                  </div>
                  <small class="form-text text-muted">{{ help_manufacturer }}</small>
                </div>
              </div>
              <div class="form-group row">
                <label class="col-sm-2 col-form-label">{{ entry_category }}</label>
                <div class="col-sm-10">
                  <input type="text" name="category" value="" placeholder="{{ entry_category }}" id="input-category" class="form-control"/>
                  <div class="input-group">
                    <div class="form-control p-0" style="height: 150px; overflow: auto;">
                      <table id="product-category" class="table table-sm m-0">
                        <tbody>
                          {% for product_category in product_categories %}
                            <tr id="product-category{{ product_category.category_id }}">
                              <td>{{ product_category.name }}<input type="hidden" name="product_category[]" value="{{ product_category.category_id }}"/></td>
                              <td class="text-right"><button type="button" class="btn btn-danger btn-sm"><i class="fas fa-minus-circle"></i></button></td>
                            </tr>
                          {% endfor %}
                        </tbody>
                      </table>
                    </div>
                    {% if master_id %}
                      <div class="input-group-append">
                        <div class="input-group-text">
                          <div class="custom-control custom-switch">
                            {% if override.product_category %}
                              <input type="checkbox" name="override[product_category]" value="1" id="input-variant-category" data-toggle="switch" data-target="#input-category, #product-category" class="custom-control-input" checked/>
                            {% else %}
                              <input type="checkbox" name="override[product_category]" value="1" id="input-variant-category" data-toggle="switch" data-target="#input-category, #product-category" class="custom-control-input"/>
                            {% endif %}
                            <label for="input-variant-category" class="custom-control-label"></label>
                          </div>
                        </div>
                      </div>
                    {% endif %}
                  </div>
                  <small class="form-text text-muted">{{ help_category }}</small>
                </div>
              </div>
              <div class="form-group row">
                <label class="col-sm-2 col-form-label">{{ entry_filter }}</label>
                <div class="col-sm-10">
                  <input type="text" name="filter" value="" placeholder="{{ entry_filter }}" id="input-filter" class="form-control"/>
                  <div class="input-group">
                    <div class="form-control p-0" style="height: 150px; overflow: auto;">
                      <table id="product-filter" class="table table-sm m-0">
                        {% for product_filter in product_filters %}
                          <tr id="product-filter{{ product_filter.filter_id }}">
                            <td>{{ product_filter.name }}<input type="hidden" name="product_filter[]" value="{{ product_filter.filter_id }}"/></td>
                            <td class="text-right"><button type="button" class="btn btn-danger btn-sm"><i class="fas fa-minus-circle"></i></button></td>
                          </tr>
                        {% endfor %}
                      </table>
                    </div>
                    {% if master_id %}
                      <div class="input-group-append">
                        <div class="input-group-text">
                          <div class="custom-control custom-switch">
                            {% if override.product_filter %}
                              <input type="checkbox" name="override[product_filter]" value="1" id="input-variant-filter" data-toggle="switch" data-target="#input-filter, #product-filter" class="custom-control-input" checked/>
                            {% else %}
                              <input type="checkbox" name="override[product_filter]" value="1" id="input-variant-filter" data-toggle="switch" data-target="#input-filter, #product-filter" class="custom-control-input"/>
                            {% endif %}
                            <label for="input-variant-filter" class="custom-control-label"></label>
                          </div>
                        </div>
                      </div>
                    {% endif %}
                  </div>
                  <small class="form-text text-muted">{{ help_filter }}</small>
                </div>
              </div>
              <div class="form-group row">
                <label class="col-sm-2 col-form-label">{{ entry_store }}</label>
                <div class="col-sm-10">
                  <div class="input-group">
                    <div id="product-store" class="form-control" style="height: 150px; overflow: auto;">
                      {% for store in stores %}
                        <label class="form-check">
                          {% if store.store_id in product_store %}
                            <input type="checkbox" name="product_store[]" value="{{ store.store_id }}" checked="checked" class="form-check-input"/>
                            {{ store.name }}
                          {% else %}
                            <input type="checkbox" name="product_store[]" value="{{ store.store_id }}" class="form-check-input"/>
                            {{ store.name }}
                          {% endif %}
                        </label>
                      {% endfor %}
                    </div>
                    {% if master_id %}
                      <div class="input-group-append">
                        <div class="input-group-text">
                          <div class="custom-control custom-switch">
                            {% if override.product_store %}
                              <input type="checkbox" name="override[product_store]" value="1" id="input-variant-store" data-toggle="switch" data-target="#product-store" class="custom-control-input" checked/>
                            {% else %}
                              <input type="checkbox" name="override[product_store]" value="1" id="input-variant-store" data-toggle="switch" data-target="#product-store" class="custom-control-input"/>
                            {% endif %}
                            <label for="input-variant-store" class="custom-control-label"></label>
                          </div>
                        </div>
                      </div>
                    {% endif %}
                  </div>
                </div>
              </div>
              <div class="form-group row">
                <label class="col-sm-2 col-form-label">{{ entry_download }}</label>
                <div class="col-sm-10">
                  <input type="text" name="download" value="" placeholder="{{ entry_download }}" id="input-download" class="form-control"/>
                  <div class="input-group">
                    <div class="form-control p-0" style="height: 150px; overflow: auto;">
                      <table id="product-download" class="table table-sm m-0">
                        {% for product_download in product_downloads %}
                          <tr id="product-download{{ product_download.download_id }}">
                            <td>{{ product_download.name }}<input type="hidden" name="product_download[]" value="{{ product_download.download_id }}"/></td>
                            <td class="text-right"><button type="button" class="btn btn-danger btn-sm"><i class="fas fa-minus-circle"></i></button></td>
                          </tr>
                        {% endfor %}
                      </table>
                    </div>
                    {% if master_id %}
                      <div class="input-group-append">
                        <div class="input-group-text">
                          <div class="custom-control custom-switch">
                            {% if override.product_download %}
                              <input type="checkbox" name="override[product_download]" value="1" id="input-variant-download" data-toggle="switch" data-target="#input-download, #product-download" class="custom-control-input" checked/>
                            {% else %}
                              <input type="checkbox" name="override[product_download]" value="1" id="input-variant-download" data-toggle="switch" data-target="#input-download, #product-download" class="custom-control-input"/>
                            {% endif %}
                            <label for="input-variant-download" class="custom-control-label"></label>
                          </div>
                        </div>
                      </div>
                    {% endif %}
                  </div>
                  <small class="form-text text-muted">{{ help_download }}</small>
                </div>
              </div>
              <div class="form-group row">
                <label class="col-sm-2 col-form-label">{{ entry_related }}</label>
                <div class="col-sm-10">
                  <input type="text" name="related" value="" placeholder="{{ entry_related }}" id="input-related" class="form-control"/>
                  <div class="input-group">
                    <div class="form-control p-0" style="height: 150px; overflow: auto;">
                      <table id="product-related" class="table table-sm m-0">
                        {% for product_related in product_relateds %}
                          <tr id="product-related{{ product_related.product_id }}">
                            <td>{{ product_related.name }}<input type="hidden" name="product_related[]" value="{{ product_related.product_id }}"/></td>
                            <td class="text-right"><button type="button" class="btn btn-danger btn-sm"><i class="fas fa-minus-circle"></i></button></td>
                          </tr>
                        {% endfor %}
                      </table>
                    </div>
                    {% if master_id %}
                      <div class="input-group-append">
                        <div class="input-group-text">
                          <div class="custom-control custom-switch">
                            {% if override.product_related %}
                              <input type="checkbox" name="override[product_related]" value="1" id="input-variant-related" data-toggle="switch" data-target="#input-related, #product-related" class="custom-control-input" checked/>
                            {% else %}
                              <input type="checkbox" name="override[product_related]" value="1" id="input-variant-related" data-toggle="switch" data-target="#input-related, #product-related" class="custom-control-input"/>
                            {% endif %}
                            <label for="input-variant-related" class="custom-control-label"></label>
                          </div>
                        </div>
                      </div>
                    {% endif %}
                  </div>
                  <small class="form-text text-muted">{{ help_related }}</small>
                </div>
              </div>
            </div>

            <div id="tab-attribute" class="tab-pane">
              <div class="table-responsive">
                <table id="product-attribute" class="table table-bordered table-hover">
                  <thead>
                    <tr>
                      <td class="text-left">{{ entry_attribute }}</td>
                      <td class="text-left">{{ entry_text }}</td>
                      <td class="text-right">
                        {% if master_id %}
                          <div class="custom-control custom-switch">
                            {% if override.product_attribute %}
                              <input type="checkbox" name="override[product_attribute]" value="1" id="input-variant-product-attribute" data-toggle="switch" data-target="#product-attribute" class="custom-control-input" checked/>
                            {% else %}
                              <input type="checkbox" name="override[product_attribute]" value="1" id="input-variant-product-attribute" data-toggle="switch" data-target="#product-attribute" class="custom-control-input"/>
                            {% endif %}
                            <label for="input-variant-product-attribute" class="custom-control-label"></label>
                          </div>
                        {% endif %}
                      </td>
                    </tr>
                  </thead>
                  <tbody>
                    {% set attribute_row = 0 %}
                    {% for product_attribute in product_attributes %}
                      <tr id="attribute-row{{ attribute_row }}">
                        <td class="text-left"><input type="text" name="product_attribute[{{ attribute_row }}][name]" value="{{ product_attribute.name }}" placeholder="{{ entry_attribute }}" class="form-control"/> <input type="hidden" name="product_attribute[{{ attribute_row }}][attribute_id]" value="{{ product_attribute.attribute_id }}"/></td>
                        <td class="text-left">
                          {% for language in languages %}
                            <div class="input-group mb-12">
                              <div class="input-group-prepend">
                                <span class="input-group-text"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}"/></span>
                              </div>
                              <textarea name="product_attribute[{{ attribute_row }}][product_attribute_description][{{ language.language_id }}][text]" rows="5" placeholder="{{ entry_text }}" class="form-control">{{ product_attribute.product_attribute_description[language.language_id] ? product_attribute.product_attribute_description[language.language_id].text }}</textarea>
                            </div>
                          {% endfor %}</td>
                        <td class="text-right"><button type="button" onclick="$('#attribute-row{{ attribute_row }}').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fas fa-minus-circle"></i></button></td>
                      </tr>
                      {% set attribute_row = attribute_row + 1 %}
                    {% endfor %}
                  </tbody>
                  <tfoot>
                    <tr>
                      <td colspan="2"></td>
                      <td class="text-right"><button type="button" id="button-attribute" data-toggle="tooltip" title="{{ button_attribute_add }}" class="btn btn-primary"><i class="fas fa-plus-circle"></i></button></td>
                    </tr>
                  </tfoot>
                </table>
              </div>
            </div>

            {% if not master_id %}
              <div id="tab-option" class="tab-pane">
                <div id="option">
                  {% set option_row = 0 %}
                  {% set option_value_row = 0 %}
                  {% for product_option in product_options %}
                    <fieldset id="option-row{{ option_row }}">
                      <legend>{{ product_option.name }} <button type="button" class="btn btn-danger btn-sm float-right" onclick="$('#option-row{{ option_row }}').remove();"><i class="fas fa-minus-circle"></i></button></legend>
                      <input type="hidden" name="product_option[{{ option_row }}][product_option_id]" value="{{ product_option.product_option_id }}"/> <input type="hidden" name="product_option[{{ option_row }}][name]" value="{{ product_option.name }}"/> <input type="hidden" name="product_option[{{ option_row }}][option_id]" value="{{ product_option.option_id }}"/> <input type="hidden" name="product_option[{{ option_row }}][type]" value="{{ product_option.type }}"/>
                      <div class="form-group row">
                        <label for="input-required{{ option_row }}" class="col-sm-2 col-form-label">{{ entry_required }}</label>
                        <div class="col-sm-10">
                          <select name="product_option[{{ option_row }}][required]" id="input-required{{ option_row }}" class="form-control">
                            {% if product_option.required %}
                              <option value="1" selected="selected">{{ text_yes }}</option>
                              <option value="0">{{ text_no }}</option>
                            {% else %}
                              <option value="1">{{ text_yes }}</option>
                              <option value="0" selected="selected">{{ text_no }}</option>
                            {% endif %}
                          </select>
                        </div>
                      </div>
                      {% if product_option.type == 'text' %}
                        <div class="form-group row">
                          <label for="input-option{{ option_row }}" class="col-sm-2 col-form-label">{{ entry_option_value }}</label>
                          <div class="col-sm-10"><input type="text" name="product_option[{{ option_row }}][value]" value="{{ product_option.value }}" placeholder="{{ entry_option_value }}" id="input-option{{ option_row }}" class="form-control"/></div>
                        </div>
                      {% endif %}
                      {% if product_option.type == 'textarea' %}
                        <div class="form-group row">
                          <label for="input-option{{ option_row }}" class="col-sm-2 col-form-label">{{ entry_option_value }}</label>
                          <div class="col-sm-10">
                            <textarea name="product_option[{{ option_row }}][value]" rows="5" placeholder="{{ entry_option_value }}" id="input-value{{ option_row }}" class="form-control">{{ product_option.value }}</textarea>
                          </div>
                        </div>
                      {% endif %}
                      {% if product_option.type == 'file' %}
                        <div class="form-group row d-none">
                          <label for="input-option{{ option_row }}" class="col-sm-2 col-form-label">{{ entry_option_value }}</label>
                          <div class="col-sm-10"><input type="text" name="product_option[{{ option_row }}][value]" value="{{ product_option.value }}" placeholder="{{ entry_option_value }}" id="input-option{{ option_row }}" class="form-control"/></div>
                        </div>
                      {% endif %}
                      {% if product_option.type == 'date' %}
                        <div class="form-group row">
                          <label for="input-option{{ option_row }}" class="col-sm-2 col-form-label">{{ entry_option_value }}</label>
                          <div class="col-sm-10 col-md-4">
                            <div class="input-group date">
                              <input type="text" name="product_option[{{ option_row }}][value]" value="{{ product_option.value }}" placeholder="{{ entry_option_value }}" id="input-option{{ option_row }}" class="form-control"/>
                              <div class="input-group-append">
                                <div class="input-group-text"><i class="fas fa-calendar"></i></div>
                              </div>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                      {% if product_option.type == 'time' %}
                        <div class="form-group row">
                          <label for="input-option{{ option_row }}" class="col-sm-2 col-form-label">{{ entry_option_value }}</label>
                          <div class="col-sm-10 col-md-4">
                            <div class="input-group time">
                              <input type="text" name="product_option[{{ option_row }}][value]" value="{{ product_option.value }}" placeholder="{{ entry_option_value }}" id="input-option{{ option_row }}" class="form-control"/>
                              <div class="input-group-append">
                                <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                              </div>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                      {% if product_option.type == 'datetime' %}
                        <div class="form-group row">
                          <label for="input-option{{ option_row }}" class="col-sm-2 col-form-label">{{ entry_option_value }}</label>
                          <div class="col-sm-10 col-md-4">
                            <div class="input-group datetime">
                              <input type="text" name="product_option[{{ option_row }}][value]" value="{{ product_option.value }}" placeholder="{{ entry_option_value }}" id="input-option{{ option_row }}" class="form-control"/>
                              <div class="input-group-append">
                                <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                              </div>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                      {% if product_option.type == 'select' or product_option.type == 'radio' or product_option.type == 'checkbox' or product_option.type == 'image' %}
                        <div class="table-responsive">
                          <table class="table table-bordered table-hover">
                            <thead>
                              <tr>
                                <td class="text-left">{{ entry_option_value }}</td>
                                <td class="text-right">{{ entry_quantity }}</td>
                                <td class="text-left">{{ entry_subtract }}</td>
                                <td class="text-right">{{ entry_price }}</td>
                                <td class="text-right">{{ entry_points }}</td>
                                <td class="text-right">{{ entry_weight }}</td>
                                <td></td>
                              </tr>
                            </thead>
                            <tbody id="option-value{{ option_row }}">
                              {% for product_option_value in product_option.product_option_value %}
                                <tr id="option-value-row{{ option_value_row }}">
                                  <td class="text-left">{{ product_option_value.name }}
                                    <input type="hidden" name="product_option[{{ option_row }}][product_option_value][{{ option_value_row }}][option_value_id]" value="{{ product_option_value.option_value_id }}"/> <input type="hidden" name="product_option[{{ option_row }}][product_option_value][{{ option_value_row }}][product_option_value_id]" value="{{ product_option_value.product_option_value_id }}"/></td>
                                  <td class="text-right">{{ product_option_value.quantity }} <input type="hidden" name="product_option[{{ option_row }}][product_option_value][{{ option_value_row }}][quantity]" value="{{ product_option_value.quantity }}"/></td>
                                  <td class="text-left">{% if product_option_value.subtract %}
                                      {{ text_yes }}
                                    {% else %}
                                      {{ text_no }}
                                    {% endif %}
                                    <input type="hidden" name="product_option[{{ option_row }}][product_option_value][{{ option_value_row }}][subtract]" value="{{ product_option_value.subtract }}"/></td>
                                  <td class="text-right">{{ product_option_value.price_prefix }}{{ product_option_value.price }}
                                    <input type="hidden" name="product_option[{{ option_row }}][product_option_value][{{ option_value_row }}][price_prefix]" value="{{ product_option_value.price_prefix }}"/> <input type="hidden" name="product_option[{{ option_row }}][product_option_value][{{ option_value_row }}][price]" value="{{ product_option_value.price }}"/></td>
                                  <td class="text-right">{{ product_option_value.points_prefix }}{{ product_option_value.points }}
                                    <input type="hidden" name="product_option[{{ option_row }}][product_option_value][{{ option_value_row }}][points_prefix]" value="{{ product_option_value.points_prefix }}"/> <input type="hidden" name="product_option[{{ option_row }}][product_option_value][{{ option_value_row }}][points]" value="{{ product_option_value.points }}"/></td>
                                  <td class="text-right">{{ product_option_value.weight_prefix }}{{ product_option_value.weight }}
                                    <input type="hidden" name="product_option[{{ option_row }}][product_option_value][{{ option_value_row }}][weight_prefix]" value="{{ product_option_value.weight_prefix }}"/> <input type="hidden" name="product_option[{{ option_row }}][product_option_value][{{ option_value_row }}][weight]" value="{{ product_option_value.weight }}"/></td>
                                  <td class="text-right"><button type="button" data-toggle="tooltip" title="{{ button_edit }}" data-option-row="{{ option_row }}" data-option-value-row="{{ option_value_row }}" class="btn btn-primary"><i class="fas fa-pencil-alt"></i></button> <button type="button" onclick="$(this).tooltip('dispose'); $('#option-value-row{{ option_value_row }}').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>
                                </tr>
                                {% set option_value_row = option_value_row + 1 %}
                              {% endfor %}
                            </tbody>
                            <tfoot>
                              <tr>
                                <td colspan="6"></td>
                                <td class="text-right"><button type="button" data-toggle="tooltip" title="{{ button_option_value_add }}" data-option-row="{{ option_row }}" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></td>
                              </tr>
                            </tfoot>
                          </table>
                          <select id="product-option-values{{ option_row }}" class="d-none">
                            {% if option_values[product_option.option_id] %}
                              {% for option_value in option_values[product_option.option_id] %}
                                <option value="{{ option_value.option_value_id }}">{{ option_value.name }}</option>
                              {% endfor %}
                            {% endif %}
                          </select>
                        </div>
                      {% endif %}
                    </fieldset>
                    {% set option_row = option_row + 1 %}
                  {% endfor %}
                </div>
                <fieldset>
                  <legend>{{ text_option_add }}</legend>
                  <div class="form-group row">
                    <label for="input-option" class="col-sm-2 col-form-label">{{ entry_option }}</label>
                    <div class="col-sm-10">
                      <input type="text" name="option" value="" placeholder="{{ entry_option }}" id="input-option" class="form-control"/>
                      <small class="form-text text-muted">{{ help_option }}</small>
                    </div>
                  </div>
                </fieldset>
              </div>
            {% else %}
              <div id="tab-option" class="tab-pane">
                {% for option in options %}
                  <fieldset>
                    <legend>{{ option.name }}</legend>
                    {% if option.type == 'select' %}
                      <div class="form-group row{% if option.required %} required{% endif %}">
                        <label class="col-sm-2 col-form-label">{{ option.name }}</label>
                        <div class="col-sm-10">
                          <div class="input-group">
                            <select name="variant[{{ option.product_option_id }}]" id="input-option{{ option.product_option_id }}" class="form-control">
                              <option value="">{{ text_select }}</option>
                              {% for option_value in option.product_option_value %}
                                {% if variant[option.product_option_id] and option_value.product_option_value_id == variant[option.product_option_id] %}
                                  <option value="{{ option_value.product_option_value_id }}" selected>{{ option_value.name }}
                                    {% if option_value.price %}
                                      ({{ option_value.price_prefix }}{{ option_value.price }})
                                    {% endif %}</option>
                                {% else %}
                                  <option value="{{ option_value.product_option_value_id }}">{{ option_value.name }}
                                    {% if option_value.price %}
                                      ({{ option_value.price_prefix }}{{ option_value.price }})
                                    {% endif %}</option>
                                {% endif %}
                              {% endfor %}
                            </select>
                            <div class="input-group-append">
                              <div class="input-group-text">
                                <div class="custom-control custom-switch">
                                  {% if override.variant[option.product_option_id] %}
                                    <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#input-option{{ option.product_option_id }}" class="custom-control-input" checked/>
                                  {% else %}
                                    <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#input-option{{ option.product_option_id }}" class="custom-control-input"/>
                                  {% endif %}
                                  <label for="input-variant-option{{ option.product_option_id }}" class="custom-control-label"></label>
                                </div>
                              </div>
                            </div>
                          </div>
                          {% if error_variant[option.product_option_id] %}
                            <div class="invalid-tooltip">{{ error_variant[option.product_option_id] }}</div>
                          {% endif %}
                        </div>
                      </div>
                    {% endif %}

                    {% if option.type == 'radio' %}
                      <div class="form-group row{% if option.required %} required{% endif %}">
                        <label class="col-sm-2 col-form-label">{{ option.name }}</label>
                        <div class="col-sm-10">
                          <div class="input-group">
                            <div id="input-option{{ option.product_option_id }}" class="form-control" style="height: 150px; overflow: auto;">
                              {% for option_value in option.product_option_value %}
                                <div class="form-check">
                                  <label>
                                    {% if variant[option.product_option_id] and option_value.product_option_value_id == variant[option.product_option_id] %}
                                      <input type="radio" name="variant[{{ option.product_option_id }}]" value="{{ option_value.product_option_value_id }}" class="form-check-input" checked/>
                                    {% else %}
                                      <input type="radio" name="variant[{{ option.product_option_id }}]" value="{{ option_value.product_option_value_id }}" class="form-check-input"/>
                                    {% endif %}
                                    {% if option_value.image %}<img src="{{ option_value.image }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail"/>{% endif %}
                                    {{ option_value.name }}
                                    {% if option_value.price %}
                                      ({{ option_value.price_prefix }}{{ option_value.price }})
                                    {% endif %}
                                  </label>
                                </div>
                              {% endfor %}
                            </div>
                            <div class="input-group-append">
                              <div class="input-group-text">
                                <div class="custom-control custom-switch">
                                  {% if override.variant[option.product_option_id] %}
                                    <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#input-option{{ option.product_option_id }}" class="custom-control-input" checked/>
                                  {% else %}
                                    <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#input-option{{ option.product_option_id }}" class="custom-control-input"/>
                                  {% endif %}
                                  <label for="input-variant-option{{ option.product_option_id }}" class="custom-control-label"></label>
                                </div>
                              </div>
                            </div>
                          </div>
                          {% if error_variant[option.product_option_id] %}
                            <div class="invalid-tooltip">{{ error_variant[option.product_option_id] }}</div>
                          {% endif %}
                        </div>
                      </div>
                    {% endif %}

                    {% if option.type == 'checkbox' %}
                      <div class="form-group row{% if option.required %} required{% endif %}">
                        <label class="col-sm-2 col-form-label">{{ option.name }}</label>
                        <div class="col-sm-10">
                          <div class="input-group">
                            <div id="input-option{{ option.product_option_id }}" class="form-control" style="height: 150px; overflow: auto;">
                              {% for option_value in option.product_option_value %}
                                <div class="form-check">
                                  <label>
                                    {% if variant[option.product_option_id] and option_value.product_option_value_id in variant[option.product_option_id] %}
                                      <input type="checkbox" name="variant[{{ option.product_option_id }}][]" value="{{ option_value.product_option_value_id }}" class="form-check-input" checked/>
                                    {% else %}
                                      <input type="checkbox" name="variant[{{ option.product_option_id }}][]" value="{{ option_value.product_option_value_id }}" class="form-check-input"/>
                                    {% endif %}
                                    {% if option_value.image %} <img src="{{ option_value.image }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail"/>{% endif %}
                                    {{ option_value.name }}
                                    {% if option_value.price %}
                                      ({{ option_value.price_prefix }}{{ option_value.price }})
                                    {% endif %}
                                  </label>
                                </div>
                              {% endfor %}
                            </div>
                            <div class="input-group-append">
                              <div class="input-group-text">
                                <div class="custom-control custom-switch">
                                  {% if override.variant[option.product_option_id] %}
                                    <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#input-option{{ option.product_option_id }}" class="custom-control-input" checked/>
                                  {% else %}
                                    <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#input-option{{ option.product_option_id }}" class="custom-control-input"/>
                                  {% endif %}
                                  <label for="input-variant-option{{ option.product_option_id }}" class="custom-control-label"></label>
                                </div>
                              </div>
                            </div>
                          </div>
                          {% if error_variant[option.product_option_id] %}
                            <div class="invalid-tooltip">{{ error_variant[option.product_option_id] }}</div>
                          {% endif %}
                        </div>
                      </div>
                    {% endif %}

                    {% if option.type == 'text' %}
                      <div class="form-group row{% if option.required %} required{% endif %}">
                        <label for="input-option{{ option.product_option_id }}" class="col-sm-2 col-form-label">{{ option.name }}</label>
                        <div class="col-sm-10">
                          <div class="input-group">
                            <input type="text" name="variant[{{ option.product_option_id }}]" value="{{ variant[option.product_option_id] ? variant[option.product_option_id] : option.value }}" placeholder="{{ option.name }}" id="input-option{{ option.product_option_id }}" class="form-control"/>
                            <div class="input-group-append">
                              <div class="input-group-text">
                                <div class="custom-control custom-switch">
                                  {% if override.variant[option.product_option_id] %}
                                    <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#input-option{{ option.product_option_id }}" class="custom-control-input" checked/>
                                  {% else %}
                                    <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#input-option{{ option.product_option_id }}" class="custom-control-input"/>
                                  {% endif %}
                                  <label for="input-variant-option{{ option.product_option_id }}" class="custom-control-label"></label>
                                </div>
                              </div>
                            </div>
                          </div>
                          {% if error_variant[option.product_option_id] %}
                            <div class="invalid-tooltip">{{ error_variant[option.product_option_id] }}</div>
                          {% endif %}
                        </div>
                      </div>
                    {% endif %}

                    {% if option.type == 'textarea' %}
                      <div class="form-group row{% if option.required %} required{% endif %}">
                        <label for="input-option{{ option.product_option_id }}" class="col-sm-2 col-form-label">{{ option.name }}</label>
                        <div class="col-sm-10">
                          <div class="input-group">
                            <textarea name="variant[{{ option.product_option_id }}]" rows="5" placeholder="{{ option.name }}" id="input-option{{ option.product_option_id }}" class="form-control">{{ variant[option.product_option_id] ? variant[option.product_option_id] : option.value }}</textarea>
                            <div class="input-group-append">
                              <div class="input-group-text">
                                <div class="custom-control custom-switch">
                                  {% if override.variant[option.product_option_id] %}
                                    <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#input-option{{ option.product_option_id }}" class="custom-control-input" checked/>
                                  {% else %}
                                    <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#input-option{{ option.product_option_id }}" class="custom-control-input"/>
                                  {% endif %}
                                  <label for="input-variant-option{{ option.product_option_id }}" class="custom-control-label"></label>
                                </div>
                              </div>
                            </div>
                          </div>
                          {% if error_variant[option.product_option_id] %}
                            <div class="invalid-tooltip">{{ error_variant[option.product_option_id] }}</div>
                          {% endif %}
                        </div>
                      </div>
                    {% endif %}

                    {% if option.type == 'file' %}
                      <div class="form-group row{% if option.required %} required{% endif %}">
                        <label class="col-sm-2 col-form-label">{{ option.name }}</label>
                        <div class="col-sm-10">
                          <div class="input-group">
                            <button type="button" id="button-upload{{ option.product_option_id }}" data-loading-text="{{ text_loading }}" class="btn btn-light"><i class="fas fa-upload"></i> {{ button_upload }}</button>
                            <input type="hidden" name="variant[{{ option.product_option_id }}]" value="{{ variant[option.product_option_id] ? variant[option.product_option_id] : option.value }}" id="input-option{{ option.product_option_id }}"/>
                            <div class="input-group-append align-items-center">
                              <div class="custom-control custom-switch">
                                {% if override.variant[option.product_option_id] %}
                                  <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#button-upload{{ option.product_option_id }}" class="custom-control-input" checked/>
                                {% else %}
                                  <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#button-upload{{ option.product_option_id }}" class="custom-control-input"/>
                                {% endif %}
                                <label for="input-variant-option{{ option.product_option_id }}" class="custom-control-label"></label>
                              </div>
                            </div>
                          </div>
                          {% if error_variant[option.product_option_id] %}
                            <div class="invalid-tooltip">{{ error_variant[option.product_option_id] }}</div>
                          {% endif %}
                        </div>
                      </div>
                    {% endif %}

                    {% if option.type == 'date' %}
                      <div class="form-group row{% if option.required %} required{% endif %}">
                        <label for="input-option{{ option.product_option_id }}" class="col-sm-2 col-form-label">{{ option.name }}</label>
                        <div class="col-sm-10 col-md-4">
                          <div class="input-group date">
                            <input type="text" name="variant[{{ option.product_option_id }}]" value="{{ variant[option.product_option_id] ? variant[option.product_option_id] : option.value }}" id="input-option{{ option.product_option_id }}" class="form-control"/>
                            <div class="input-group-append">
                              <span class="input-group-text"><i class="fas fa-calendar"></i></span>
                            </div>
                            <div class="input-group-append">
                              <div class="input-group-text">
                                <div class="custom-control custom-switch">
                                  {% if override.variant[option.product_option_id] %}
                                    <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#input-option{{ option.product_option_id }}" class="custom-control-input" checked/>
                                  {% else %}
                                    <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#input-option{{ option.product_option_id }}" class="custom-control-input"/>
                                  {% endif %}
                                  <label for="input-variant-option{{ option.product_option_id }}" class="custom-control-label"></label>
                                </div>
                              </div>
                            </div>
                          </div>
                          {% if error_variant[option.product_option_id] %}
                            <div class="invalid-tooltip">{{ error_variant[option.product_option_id] }}</div>
                          {% endif %}
                        </div>
                      </div>
                    {% endif %}

                    {% if option.type == 'time' %}
                      <div class="form-group row{% if option.required %} required{% endif %}">
                        <label for="input-option{{ option.product_option_id }}" class="col-sm-2 col-form-label">{{ option.name }}</label>
                        <div class="col-sm-10 col-md-4">
                          <div class="input-group time">
                            <input type="text" name="variant[{{ option.product_option_id }}]" value="{{ variant[option.product_option_id] ? variant[option.product_option_id] : option.value }}" id="input-option{{ option.product_option_id }}" class="form-control"/>
                            <div class="input-group-append">
                              <span class="input-group-text"><i class="fas fa-calendar"></i></span>
                            </div>
                            <div class="input-group-append">
                              <div class="input-group-text">
                                <div class="custom-control custom-switch">
                                  {% if override.variant[option.product_option_id] %}
                                    <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#input-option{{ option.product_option_id }}" class="custom-control-input" checked/>
                                  {% else %}
                                    <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#input-option{{ option.product_option_id }}" class="custom-control-input"/>
                                  {% endif %}
                                  <label for="input-variant-option{{ option.product_option_id }}" class="custom-control-label"></label>
                                </div>
                              </div>
                            </div>
                          </div>
                          {% if error_variant[option.product_option_id] %}
                            <div class="invalid-tooltip">{{ error_variant[option.product_option_id] }}</div>
                          {% endif %}
                        </div>
                      </div>
                    {% endif %}

                    {% if option.type == 'datetime' %}
                      <div class="form-group row{% if option.required %} required{% endif %}">
                        <label for="input-option{{ option.product_option_id }}" class="col-sm-2 col-form-label">{{ option.name }}</label>
                        <div class="col-sm-10 col-md-4">
                          <div class="input-group datetime">
                            <input type="text" name="variant[{{ option.product_option_id }}]" value="{{ variant[option.product_option_id] ? variant[option.product_option_id] : option.value }}" id="input-option{{ option.product_option_id }}" class="form-control"/>
                            <div class="input-group-append">
                              <span class="input-group-text"><i class="fas fa-calendar"></i></span>
                            </div>
                            <div class="input-group-append">
                              <div class="input-group-text">
                                <div class="custom-control custom-switch">
                                  {% if override.variant[option.product_option_id] %}
                                    <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#input-option{{ option.product_option_id }}" class="custom-control-input" checked/>
                                  {% else %}
                                    <input type="checkbox" name="override[variant][{{ option.product_option_id }}]" value="1" id="input-variant-option{{ option.product_option_id }}" data-toggle="switch" data-target="#input-option{{ option.product_option_id }}" class="custom-control-input"/>
                                  {% endif %}
                                  <label for="input-variant-option{{ option.product_option_id }}" class="custom-control-label"></label>
                                </div>
                              </div>
                            </div>
                          </div>
                          {% if error_variant[option.product_option_id] %}
                            <div class="invalid-tooltip">{{ error_variant[option.product_option_id] }}</div>
                          {% endif %}
                        </div>
                      </div>
                    {% endif %}

                  </fieldset>
                {% endfor %}
              </div>
            {% endif %}

            <div id="tab-recurring" class="tab-pane">
              <div class="table-responsive">
                <table id="product-recurring" class="table table-bordered table-hover">
                  <thead>
                    <tr>
                      <td class="text-left">{{ entry_recurring }}</td>
                      <td class="text-left">{{ entry_customer_group }}</td>
                      <td class="text-right">
                        {% if master_id %}
                          <div class="custom-control custom-switch">
                            {% if override.product_recurring %}
                              <input type="checkbox" name="override[product_recurring]" value="1" id="input-variant-product-recurring" data-toggle="switch" data-target="#product-recurring" class="custom-control-input" checked/>
                            {% else %}
                              <input type="checkbox" name="override[product_recurring]" value="1" id="input-variant-product-recurring" data-toggle="switch" data-target="#product-recurring" class="custom-control-input"/>
                            {% endif %}
                            <label for="input-variant-product-recurring" class="custom-control-label"></label>
                          </div>
                        {% endif %}
                      </td>
                    </tr>
                  </thead>
                  <tbody>
                    {% set recurring_row = 0 %}
                    {% for product_recurring in product_recurrings %}
                      <tr id="recurring-row{{ recurring_row }}">
                        <td class="text-left"><select name="product_recurring[{{ recurring_row }}][recurring_id]" class="form-control">
                            {% for recurring in recurrings %}
                              {% if recurring.recurring_id == product_recurring.recurring_id %}
                                <option value="{{ recurring.recurring_id }}" selected="selected">{{ recurring.name }}</option>
                              {% else %}
                                <option value="{{ recurring.recurring_id }}">{{ recurring.name }}</option>
                              {% endif %}
                            {% endfor %}
                          </select></td>
                        <td class="text-left"><select name="product_recurring[{{ recurring_row }}][customer_group_id]" class="form-control">
                            {% for customer_group in customer_groups %}
                              {% if customer_group.customer_group_id == product_recurring.customer_group_id %}
                                <option value="{{ customer_group.customer_group_id }}" selected="selected">{{ customer_group.name }}</option>
                              {% else %}
                                <option value="{{ customer_group.customer_group_id }}">{{ customer_group.name }}</option>
                              {% endif %}
                            {% endfor %}
                          </select></td>
                        <td class="text-right"><button type="button" onclick="$('#recurring-row{{ recurring_row }}').remove()" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fas fa-minus-circle"></i></button></td>
                      </tr>
                      {% set recurring_row = recurring_row + 1 %}
                    {% endfor %}
                  </tbody>
                  <tfoot>
                    <tr>
                      <td colspan="2"></td>
                      <td class="text-right"><button type="button" id="button-recurring" data-toggle="tooltip" title="{{ button_recurring_add }}" class="btn btn-primary"><i class="fas fa-plus-circle"></i></button></td>
                    </tr>
                  </tfoot>
                </table>
              </div>
            </div>

            <div id="tab-discount" class="tab-pane">
              <div class="table-responsive">
                <table id="product-discount" class="table table-bordered table-hover">
                  <thead>
                    <tr>
                      <td class="text-left">{{ entry_customer_group }}</td>
                      <td class="text-right">{{ entry_quantity }}</td>
                      <td class="text-right">{{ entry_priority }}</td>
                      <td class="text-right">{{ entry_price }}</td>
                      <td class="text-left">{{ entry_date_start }}</td>
                      <td class="text-left">{{ entry_date_end }}</td>
                      <td class="text-right">{% if master_id %}
                          <div class="custom-control custom-switch">
                            {% if override.product_discount %}
                              <input type="checkbox" name="override[product_discount]" value="1" id="input-variant-product-discount" data-toggle="switch" data-target="#product-discount" class="custom-control-input" checked/>
                            {% else %}
                              <input type="checkbox" name="override[product_discount]" value="1" id="input-variant-product-discount" data-toggle="switch" data-target="#product-discount" class="custom-control-input"/>
                            {% endif %}
                            <label for="input-variant-product-discount" class="custom-control-label"></label>
                          </div>
                        {% endif %}</td>
                    </tr>
                  </thead>
                  <tbody>
                    {% set discount_row = 0 %}
                    {% for product_discount in product_discounts %}
                      <tr id="discount-row{{ discount_row }}">
                        <td class="text-left"><select name="product_discount[{{ discount_row }}][customer_group_id]" class="form-control">
                            {% for customer_group in customer_groups %}
                              {% if customer_group.customer_group_id == product_discount.customer_group_id %}
                                <option value="{{ customer_group.customer_group_id }}" selected="selected">{{ customer_group.name }}</option>
                              {% else %}
                                <option value="{{ customer_group.customer_group_id }}">{{ customer_group.name }}</option>
                              {% endif %}
                            {% endfor %}
                          </select></td>
                        <td class="text-right"><input type="text" name="product_discount[{{ discount_row }}][quantity]" value="{{ product_discount.quantity }}" placeholder="{{ entry_quantity }}" class="form-control"/></td>
                        <td class="text-right"><input type="text" name="product_discount[{{ discount_row }}][priority]" value="{{ product_discount.priority }}" placeholder="{{ entry_priority }}" class="form-control"/></td>
                        <td class="text-right"><input type="text" name="product_discount[{{ discount_row }}][price]" value="{{ product_discount.price }}" placeholder="{{ entry_price }}" class="form-control"/></td>
                        <td class="text-left">
                          <div class="input-group date">
                            <input type="text" name="product_discount[{{ discount_row }}][date_start]" value="{{ product_discount.date_start }}" placeholder="{{ entry_date_start }}" class="form-control"/>
                            <div class="input-group-append">
                              <div class="input-group-text"><i class="fas fa-calendar"></i></div>
                            </div>
                          </div>
                        </td>
                        <td class="text-left">
                          <div class="input-group date">
                            <input type="text" name="product_discount[{{ discount_row }}][date_end]" value="{{ product_discount.date_end }}" placeholder="{{ entry_date_end }}" class="form-control"/>
                            <div class="input-group-append">
                              <div class="input-group-text"><i class="fas fa-calendar"></i></div>
                            </div>
                          </div>
                        </td>
                        <td class="text-right"><button type="button" onclick="$('#discount-row{{ discount_row }}').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fas fa-minus-circle"></i></button></td>
                      </tr>
                      {% set discount_row = discount_row + 1 %}
                    {% endfor %}
                  </tbody>
                  <tfoot>
                    <tr>
                      <td colspan="6"></td>
                      <td class="text-right"><button type="button" id="button-discount" data-toggle="tooltip" title="{{ button_discount_add }}" class="btn btn-primary"><i class="fas fa-plus-circle"></i></button></td>
                    </tr>
                  </tfoot>
                </table>
              </div>
            </div>

            <div id="tab-special" class="tab-pane">
              <div class="table-responsive">
                <table id="product-special" class="table table-bordered table-hover">
                  <thead>
                    <tr>
                      <td class="text-left">{{ entry_customer_group }}</td>
                      <td class="text-right">{{ entry_priority }}</td>
                      <td class="text-right">{{ entry_price }}</td>
                      <td class="text-left">{{ entry_date_start }}</td>
                      <td class="text-left">{{ entry_date_end }}</td>
                      <td class="text-right">{% if master_id %}
                          <div class="custom-control custom-switch">
                            {% if override.product_special %}
                              <input type="checkbox" name="override[product_special]" value="1" id="input-variant-special" data-toggle="switch" data-target="#product-special" class="custom-control-input" checked/>
                            {% else %}
                              <input type="checkbox" name="override[product_special]" value="1" id="input-variant-special" data-toggle="switch" data-target="#product-special" class="custom-control-input"/>
                            {% endif %}
                            <label for="input-variant-special" class="custom-control-label"></label>
                          </div>
                        {% endif %}</td>
                    </tr>
                  </thead>
                  <tbody>
                    {% set special_row = 0 %}
                    {% for product_special in product_specials %}
                      <tr id="special-row{{ special_row }}">
                        <td class="text-left"><select name="product_special[{{ special_row }}][customer_group_id]" class="form-control">
                            {% for customer_group in customer_groups %}
                              {% if customer_group.customer_group_id == product_special.customer_group_id %}
                                <option value="{{ customer_group.customer_group_id }}" selected="selected">{{ customer_group.name }}</option>
                              {% else %}
                                <option value="{{ customer_group.customer_group_id }}">{{ customer_group.name }}</option>
                              {% endif %}
                            {% endfor %}
                          </select></td>
                        <td class="text-right"><input type="text" name="product_special[{{ special_row }}][priority]" value="{{ product_special.priority }}" placeholder="{{ entry_priority }}" class="form-control"/></td>
                        <td class="text-right"><input type="text" name="product_special[{{ special_row }}][price]" value="{{ product_special.price }}" placeholder="{{ entry_price }}" class="form-control"/></td>
                        <td class="text-left">
                          <div class="input-group date">
                            <input type="text" name="product_special[{{ special_row }}][date_start]" value="{{ product_special.date_start }}" placeholder="{{ entry_date_start }}" class="form-control"/>
                            <div class="input-group-append">
                              <div class="input-group-text"><i class="fas fa-calendar"></i></div>
                            </div>
                          </div>
                        </td>
                        <td class="text-left">
                          <div class="input-group date">
                            <input type="text" name="product_special[{{ special_row }}][date_end]" value="{{ product_special.date_end }}" placeholder="{{ entry_date_end }}" class="form-control"/>
                            <div class="input-group-append">
                              <div class="input-group-text"><i class="fas fa-calendar"></i></div>
                            </div>
                          </div>
                        </td>
                        <td class="text-right"><button type="button" onclick="$('#special-row{{ special_row }}').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fas fa-minus-circle"></i></button></td>
                      </tr>
                      {% set special_row = special_row + 1 %}
                    {% endfor %}
                  </tbody>
                  <tfoot>
                    <tr>
                      <td colspan="5"></td>
                      <td class="text-right"><button type="button" id="button-special" data-toggle="tooltip" title="{{ button_special_add }}" class="btn btn-primary"><i class="fas fa-plus-circle"></i></button></td>
                    </tr>
                  </tfoot>
                </table>
              </div>
            </div>

            <div id="tab-image" class="tab-pane">
              <fieldset>
                <legend>{{ text_image }}</legend>
                <div class="row">
                  <div class="col-sm-4 col-md-3 mb-3">
                    <div id="image" class="card image">
                      <img src="{{ thumb }}" alt="" title="" id="thumb-image" data-placeholder="{{ placeholder }}" class="card-img-top"/> <input type="hidden" name="image" value="{{ image }}" id="input-image"/>
                      <div class="card-body">
                        <button type="button" data-toggle="image" data-target="#input-image" data-thumb="#thumb-image" class="btn btn-primary btn-sm btn-block"><i class="fas fa-pencil-alt"></i> {{ button_edit }}</button>
                        <button type="button" data-toggle="clear" data-target="#input-image" data-thumb="#thumb-image" class="btn btn-warning btn-sm btn-block"><i class="fas fa-trash-alt"></i> {{ button_clear }}</button>
                        {% if master_id %}
                          <div class="mx-auto w-25">
                            <div class="custom-control custom-switch">
                              {% if override.product_image %}
                                <input type="checkbox" name="override[product_image]" value="1" id="input-variant-image" data-toggle="switch" data-target="#image" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[product_image]" value="1" id="input-variant-image" data-toggle="switch" data-target="#image" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-image" class="custom-control-label"></label>
                            </div>
                          </div>
                        {% endif %}
                      </div>
                    </div>
                  </div>
                </div>
              </fieldset>
              <fieldset>
                <legend>{{ text_image_additional }}</legend>
                <div class="table-responsive">
                  <table id="product-image" class="table table-bordered table-hover">
                    <thead>
                      <tr>
                        <td class="text-left">{{ entry_image }}</td>
                        <td class="text-left">{{ entry_sort_order }}</td>
                        <td class="text-right">{% if master_id %}
                            <div class="custom-control custom-switch">
                              {% if override.product_image %}
                                <input type="checkbox" name="override[product_image]" value="1" id="input-variant-product-image" data-toggle="switch" data-target="#product-image" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[product_image]" value="1" id="input-variant-product-image" data-toggle="switch" data-target="#product-image" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-product-image" class="custom-control-label"></label>
                            </div>
                          {% endif %}</td>
                      </tr>
                    </thead>
                    <tbody>
                      {% set image_row = 0 %}
                      {% for product_image in product_images %}
                        <tr id="image-row{{ image_row }}">
                          <td>
                            <div class="card image">
                              <img src="{{ product_image.thumb }}" alt="" title="" id="thumb-image{{ image_row }}" data-placeholder="{{ placeholder }}" class="card-img-top"/> <input type="hidden" name="product_image[{{ image_row }}][image]" value="{{ product_image.image }}" id="input-image{{ image_row }}"/>
                              <div class="card-body">
                                <button type="button" data-toggle="image" data-target="#input-image{{ image_row }}" data-thumb="#thumb-image{{ image_row }}" class="btn btn-primary btn-sm btn-block"><i class="fas fa-pencil-alt"></i> {{ button_edit }}</button>
                                <button type="button" data-toggle="clear" data-target="#input-image{{ image_row }}" data-thumb="#thumb-image{{ image_row }}" class="btn btn-warning btn-sm btn-block"><i class="fas fa-trash-alt"></i> {{ button_clear }}</button>
                              </div>
                            </div>
                          </td>
                          <td class="text-left"><input type="text" name="product_image[{{ image_row }}][sort_order]" value="{{ product_image.sort_order }}" placeholder="{{ entry_sort_order }}" class="form-control"/></td>
                          <td class="text-right"><button type="button" onclick="$('#image-row{{ image_row }}').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fas fa-minus-circle"></i></button></td>
                        </tr>
                        {% set image_row = image_row + 1 %}
                      {% endfor %}
                    </tbody>
                    <tfoot>
                      <tr>
                        <td colspan="2"></td>
                        <td class="text-right"><button type="button" id="button-image" data-toggle="tooltip" title="{{ button_image_add }}" class="btn btn-primary"><i class="fas fa-plus-circle"></i></button></td>
                      </tr>
                    </tfoot>
                  </table>
                </div>
              </fieldset>
            </div>

            <div id="tab-reward" class="tab-pane">
              <fieldset>
                <legend>{{ text_reward }}</legend>
                <div class="form-group row">
                  <label for="input-points" class="col-sm-2 col-form-label">{{ entry_points }}</label>
                  <div class="col-sm-10">
                    <div class="input-group">
                      <input type="text" name="points" value="{{ points }}" placeholder="{{ entry_points }}" id="input-points" class="form-control"/>
                      {% if master_id %}
                        <div class="input-group-append">
                          <div class="input-group-text">
                            <div class="custom-control custom-switch">
                              {% if override.points %}
                                <input type="checkbox" name="override[points]" value="1" id="input-variant-points" data-toggle="switch" data-target="#input-points" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[points]" value="1" id="input-variant-points" data-toggle="switch" data-target="#input-points" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-points" class="custom-control-label"></label>
                            </div>
                          </div>
                        </div>
                      {% endif %}
                    </div>
                    <small class="form-text text-muted">{{ help_points }}</small>
                  </div>
                </div>
              </fieldset>
              <fieldset>
                <legend>{{ text_points }}</legend>
                <div class="table-responsive">
                  <table id="product-reward" class="table table-bordered table-hover">
                    <thead>
                      <tr>
                        <td class="text-left">{{ entry_customer_group }}</td>
                        <td class="text-right">{{ entry_reward }}
                          {% if master_id %}
                            <div class="custom-control custom-switch float-right">
                              {% if override.product_reward %}
                                <input type="checkbox" name="override[product_reward]" value="1" id="input-variant-product-reward" data-toggle="switch" data-target="#product-reward" class="custom-control-input" checked/>
                              {% else %}
                                <input type="checkbox" name="override[product_reward]" value="1" id="input-variant-product-reward" data-toggle="switch" data-target="#product-reward" class="custom-control-input"/>
                              {% endif %}
                              <label for="input-variant-product-reward" class="custom-control-label"></label>
                            </div>
                          {% endif %}
                        </td>
                      </tr>
                    </thead>
                    <tbody>
                      {% for customer_group in customer_groups %}
                        <tr>
                          <td class="text-left">{{ customer_group.name }}</td>
                          <td class="text-right"><input type="text" name="product_reward[{{ customer_group.customer_group_id }}][points]" value="{{ product_reward[customer_group.customer_group_id] ? product_reward[customer_group.customer_group_id].points }}" class="form-control"/></td>
                        </tr>
                      {% endfor %}
                    </tbody>
                  </table>
                </div>
              </fieldset>
            </div>

            <div id="tab-seo" class="tab-pane">
              <div class="alert alert-info"><i class="fas fa-info-circle"></i> {{ text_keyword }}</div>
              <div id="product-seo" class="table-responsive">
                <table class="table table-bordered table-hover">
                  <thead>
                    <tr>
                      <td class="text-left">{{ entry_store }}</td>
                      <td class="text-left">{{ entry_keyword }}</td>
                    </tr>
                  </thead>
                  <tbody>
                    {% for store in stores %}
                      <tr>
                        <td class="text-left">{{ store.name }}</td>
                        <td class="text-left">
                          {% for language in languages %}
                            <div class="input-group">
                              <div class="input-group-prepend">
                                <span class="input-group-text"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}"/></span>
                              </div>
                              <input type="text" name="product_seo_url[{{ store.store_id }}][{{ language.language_id }}]" value="{% if product_seo_url[store.store_id][language.language_id] %}{{ product_seo_url[store.store_id][language.language_id] }}{% endif %}" placeholder="{{ entry_keyword }}" class="form-control"/>
                            </div>
                            {% if error_keyword[store.store_id][language.language_id] %}
                              <div class="invalid-tooltip">{{ error_keyword[store.store_id][language.language_id] }}</div>
                            {% endif %}
                          {% endfor %}</td>
                      </tr>
                    {% endfor %}
                  </tbody>
                </table>
              </div>
            </div>

            <div id="tab-design" class="tab-pane">
              <div class="table-responsive">
                <table id="product-layout" class="table table-bordered table-hover">
                  <thead>
                    <tr>
                      <td class="text-left">{{ entry_store }}</td>
                      <td class="text-left">{{ entry_layout }}
                        {% if master_id %}
                          <div class="custom-control custom-switch float-right">
                            {% if override.product_layout %}
                              <input type="checkbox" name="override[product_layout]" value="1" id="input-variant-product-layout" data-toggle="switch" data-target="#product-layout" class="custom-control-input" checked/>
                            {% else %}
                              <input type="checkbox" name="override[product_layout]" value="1" id="input-variant-product-layout" data-toggle="switch" data-target="#product-layout" class="custom-control-input"/>
                            {% endif %}
                            <label for="input-variant-product-layout" class="custom-control-label"></label>
                          </div>
                        {% endif %}
                      </td>
                    </tr>
                  </thead>
                  <tbody>
                    {% for store in stores %}
                      <tr>
                        <td class="text-left">{{ store.name }}</td>
                        <td class="text-left"><select name="product_layout[{{ store.store_id }}]" class="form-control">
                            <option value=""></option>
                            {% for layout in layouts %}
                              {% if product_layout[store.store_id] and product_layout[store.store_id] == layout.layout_id %}
                                <option value="{{ layout.layout_id }}" selected="selected">{{ layout.name }}</option>
                              {% else %}
                                <option value="{{ layout.layout_id }}">{{ layout.name }}</option>
                              {% endif %}
                            {% endfor %}
                          </select></td>
                      </tr>
                    {% endfor %}
                  </tbody>
                </table>
              </div>
            </div>

          </div>
        </form>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript"><!--
$('textarea[data-toggle=\'ckeditor\']').ckeditor();

// Manufacturer
$('input[name=\'manufacturer\']').autocomplete({
	'source': function(request, response) {
		$.ajax({
			url: 'index.php?route=catalog/manufacturer/autocomplete&user_token={{ user_token }}&filter_name=' + encodeURIComponent(request),
			dataType: 'json',
			success: function(json) {
				json.unshift({
					manufacturer_id: 0,
					name: '{{ text_none }}'
				});

				response($.map(json, function(item) {
					return {
						label: item['name'],
						value: item['manufacturer_id']
					}
				}));
			}
		});
	},
	'select': function(item) {
		$('input[name=\'manufacturer\']').val(item['label']);
		$('input[name=\'manufacturer_id\']').val(item['value']);
	}
});

// Category
$('input[name=\'category\']').autocomplete({
	'source': function(request, response) {
		$.ajax({
			url: 'index.php?route=catalog/category/autocomplete&user_token={{ user_token }}&filter_name=' + encodeURIComponent(request),
			dataType: 'json',
			success: function(json) {
				response($.map(json, function(item) {
					return {
						label: item['name'],
						value: item['category_id']
					}
				}));
			}
		});
	},
	'select': function(item) {
		$('input[name=\'category\']').val('');

		$('#product-category' + item['value']).remove();

		html = '<tr id="product-category' + item['value'] + '">';
		html += '  <td>' + item['label'] + '<input type="hidden" name="product_category[]" value="' + item['value'] + '"/></td>';
		html += '  <td class="text-right"><button type="button" class="btn btn-danger btn-sm"><i class="fas fa-minus-circle"></i></button></td>';
		html += '</tr>';

		$('#product-category').append(html);
	}
});

$('#product-category').on('click', '.btn', function() {
	$(this).parent().parent().remove();
});

// Filter
$('input[name=\'filter\']').autocomplete({
	'source': function(request, response) {
		$.ajax({
			url: 'index.php?route=catalog/filter/autocomplete&user_token={{ user_token }}&filter_name=' + encodeURIComponent(request),
			dataType: 'json',
			success: function(json) {
				response($.map(json, function(item) {
					return {
						label: item['name'],
						value: item['filter_id']
					}
				}));
			}
		});
	},
	'select': function(item) {
		$('input[name=\'filter\']').val('');

		$('#product-filter' + item['value']).remove();

		html = '<tr id="product-filter' + item['value'] + '">';
		html += '  <td>' + item['label'] + '<input type="hidden" name="product_filter[]" value="' + item['value'] + '"/></td>';
		html += '  <td class="text-right"><button type="button" class="btn btn-danger btn-sm"><i class="fas fa-minus-circle"></i></button></td>';
		html += '</tr>';

		$('#product-filter').append(html);
	}
});

$('#product-filter').on('click', '.btn', function() {
	$(this).parent().parent().remove();
});

// Downloads
$('input[name=\'download\']').autocomplete({
	'source': function(request, response) {
		$.ajax({
			url: 'index.php?route=catalog/download/autocomplete&user_token={{ user_token }}&filter_name=' + encodeURIComponent(request),
			dataType: 'json',
			success: function(json) {
				response($.map(json, function(item) {
					return {
						label: item['name'],
						value: item['download_id']
					}
				}));
			}
		});
	},
	'select': function(item) {
		$('input[name=\'download\']').val('');

		$('#product-download' + item['value']).remove();

		html = '<tr id="product-download' + item['value'] + '">';
		html += '  <td>' + item['label'] + '<input type="hidden" name="product_download[]" value="' + item['value'] + '"/></td>';
		html += '  <td class="text-right"><button type="button" class="btn btn-danger btn-sm"><i class="fas fa-minus-circle"></i></button></td>';
		html += '</tr>';

		$('#product-download').append(html);
	}
});

$('#product-download').on('click', '.btn', function() {
	$(this).parent().parent().remove();
});

// Related
$('input[name=\'related\']').autocomplete({
	'source': function(request, response) {
		$.ajax({
			url: 'index.php?route=catalog/product/autocomplete&user_token={{ user_token }}&filter_name=' + encodeURIComponent(request),
			dataType: 'json',
			success: function(json) {
				response($.map(json, function(item) {
					return {
						label: item['name'],
						value: item['product_id']
					}
				}));
			}
		});
	},
	'select': function(item) {
		$('input[name=\'related\']').val('');

		$('#product-related' + item['value']).remove();

		html = '<tr id="product-related' + item['value'] + '">';
		html += '  <td>' + item['label'] + '<input type="hidden" name="product_related[]" value="' + item['value'] + '"/></td>';
		html += '  <td class="text-right"><button type="button" class="btn btn-danger btn-sm"><i class="fas fa-minus-circle"></i></button></td>';
		html += '</tr>';

		$('#product-related').append(html);
	}
});

$('#product-related').on('click', '.btn', function() {
	$(this).parent().parent().remove();
});
//--></script>
<script type="text/javascript"><!--
var attribute_row = {{ attribute_row }};

$('#button-attribute').on('click', function() {
	html = '<tr id="attribute-row' + attribute_row + '">';
	html += '  <td class="text-left"><input type="text" name="product_attribute[' + attribute_row + '][name]" value="" placeholder="{{ entry_attribute }}" class="form-control" /><input type="hidden" name="product_attribute[' + attribute_row + '][attribute_id]" value="" /></td>';
	html += '  <td class="text-left">';
  {% for language in languages %}
	html += '<div class="input-group">';
	html += '  <div class="input-group-prepend"><span class="input-group-text"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /></span></div>';
	html += '  <textarea name="product_attribute[' + attribute_row + '][product_attribute_description][{{ language.language_id }}][text]" rows="5" placeholder="{{ entry_text }}" class="form-control"></textarea>';
	html += '</div>';
  {% endfor %}
	html += '  </td>';
	html += '  <td class="text-right"><button type="button" onclick="$(\'#attribute-row' + attribute_row + '\').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fas fa-minus-circle"></i></button></td>';
	html += '</tr>';

	$('#product-attribute').append(html);

	attributeautocomplete(attribute_row);

	attribute_row++;
});

function attributeautocomplete(attribute_row) {
	$('input[name=\'product_attribute[' + attribute_row + '][name]\']').autocomplete({
		'source': function(request, response) {
			$.ajax({
				url: 'index.php?route=catalog/attribute/autocomplete&user_token={{ user_token }}&filter_name=' + encodeURIComponent(request),
				dataType: 'json',
				success: function(json) {
					response($.map(json, function(item) {
						return {
							category: item.attribute_group,
							label: item.name,
							value: item.attribute_id
						}
					}));
				}
			});
		},
		'select': function(item) {
			$('input[name=\'product_attribute[' + attribute_row + '][name]\']').val(item['label']);
			$('input[name=\'product_attribute[' + attribute_row + '][attribute_id]\']').val(item['value']);
		}
	});
}

$('#product-attribute tr').each(function(index, element) {
	attributeautocomplete(index);
});
//--></script>
<script type="text/javascript"><!--
{% if not master_id %}
var option_row = {{ option_row }};

$('input[name=\'option\']').autocomplete({
	'source': function(request, response) {
		$.ajax({
			url: 'index.php?route=catalog/option/autocomplete&user_token={{ user_token }}&filter_name=' + encodeURIComponent(request),
			dataType: 'json',
			success: function(json) {
				response($.map(json, function(item) {
					return {
						category: item['category'],
						label: item['name'],
						value: item['option_id'],
						type: item['type'],
						option_value: item['option_value']
					}
				}));
			}
		});
	},
	'select': function(item) {
		html = '<fieldset id="option-row' + option_row + '">';
		html += '  <legend>' + item['label'] + ' <button type="button" class="btn btn-danger btn-sm float-right" onclick="$(\'#option-row' + option_row + '\').remove();"><i class="fas fa-minus-circle"></i></button></legend>';
		html += '  <input type="hidden" name="product_option[' + option_row + '][product_option_id]" value="" />';
		html += '  <input type="hidden" name="product_option[' + option_row + '][name]" value="' + item['label'] + '" />';
		html += '  <input type="hidden" name="product_option[' + option_row + '][option_id]" value="' + item['value'] + '" />';
		html += '  <input type="hidden" name="product_option[' + option_row + '][type]" value="' + item['type'] + '" />';

		html += '  <div class="form-group row">';
		html += '    <label for="input-required' + option_row + '" class="col-sm-2 col-form-label">{{ entry_required }}</label>';
		html += '	 <div class="col-sm-10"><select name="product_option[' + option_row + '][required]" id="input-required' + option_row + '" class="form-control">';
		html += '	   <option value="1">{{ text_yes }}</option>';
		html += '	   <option value="0">{{ text_no }}</option>';
		html += '	 </select></div>';
		html += '  </div>';

		if (item['type'] == 'text') {
			html += '	<div class="form-group row">';
			html += '	  <label for="input-option' + option_row + '" class="col-sm-2 col-form-label">{{ entry_option_value }}</label>';
			html += '	  <div class="col-sm-10"><input type="text" name="product_option[' + option_row + '][value]" value="" placeholder="{{ entry_option_value }}" id="input-option' + option_row + '" class="form-control" /></div>';
			html += '	</div>';
		}

		if (item['type'] == 'textarea') {
			html += '	<div class="form-group row">';
			html += '	  <label for="input-option' + option_row + '" class="col-sm-2 col-form-label">{{ entry_option_value }}</label>';
			html += '	  <div class="col-sm-10"><textarea name="product_option[' + option_row + '][value]" rows="5" placeholder="{{ entry_option_value }}" id="input-option' + option_row + '" class="form-control"></textarea></div>';
			html += '	</div>';
		}

		if (item['type'] == 'file') {
			html += '	<div class="form-group row d-none">';
			html += '	  <label for="input-option' + option_row + '" class="col-sm-2 col-form-label">{{ entry_option_value }}</label>';
			html += '	  <div class="col-sm-10 d-none"><input type="text" name="product_option[' + option_row + '][value]" value="" placeholder="{{ entry_option_value }}" id="input-option' + option_row + '" class="form-control" /></div>';
			html += '	</div>';
		}

		if (item['type'] == 'date') {
			html += '	<div class="form-group row">';
			html += '	  <label for="input-option' + option_row + '" class="col-sm-2 col-form-label">{{ entry_option_value }}</label>';
			html += '	  <div class="col-sm-10 col-md-4"><div class="input-group date"><input type="text" name="product_option[' + option_row + '][value]" value="" placeholder="{{ entry_option_value }}" id="input-option' + option_row + '" class="form-control" /><div class="input-group-append"><div class="input-group-text"><i class="fa fa-calendar"></i></div></div></div></div>';
			html += '	</div>';
		}

		if (item['type'] == 'time') {
			html += '	<div class="form-group row">';
			html += '	  <label for="input-option' + option_row + '" class="col-sm-2 col-form-label">{{ entry_option_value }}</label>';
			html += '	  <div class="col-sm-10 col-md-4"><div class="input-group time"><input type="text" name="product_option[' + option_row + '][value]" value="" placeholder="{{ entry_option_value }}" id="input-option' + option_row + '" class="form-control" /><div class="input-group-append"><div class="input-group-text"><i class="fa fa-calendar"></i></div></div></div></div>';
			html += '	</div>';
		}

		if (item['type'] == 'datetime') {
			html += '	<div class="form-group row">';
			html += '	  <label for="input-option' + option_row + '" class="col-sm-2 col-form-label">{{ entry_option_value }}</label>';
			html += '	  <div class="col-sm-10 col-md-4"><div class="input-group datetime"><input type="text" name="product_option[' + option_row + '][value]" value="" placeholder="{{ entry_option_value }}" id="input-option' + option_row + '" class="form-control" /><div class="input-group-append"><div class="input-group-text"><i class="fa fa-calendar"></i></div></div></div></div>';
			html += '	</div>';
		}

		if (item['type'] == 'select' || item['type'] == 'radio' || item['type'] == 'checkbox' || item['type'] == 'image') {
			html += '<div class="table-responsive">';
			html += '  <table id="option-value' + option_row + '" class="table table-bordered table-hover">';
			html += '  	 <thead>';
			html += '      <tr>';
			html += '        <td class="text-left">{{ entry_option_value }}</td>';
			html += '        <td class="text-right">{{ entry_quantity }}</td>';
			html += '        <td class="text-left">{{ entry_subtract }}</td>';
			html += '        <td class="text-right">{{ entry_price }}</td>';
			html += '        <td class="text-right">{{ entry_points }}</td>';
			html += '        <td class="text-right">{{ entry_weight }}</td>';
			html += '        <td></td>';
			html += '      </tr>';
			html += '    </thead>';
			html += '    <tbody></tbody>';
			html += '    <tfoot>';
			html += '      <tr>';
			html += '        <td colspan="5"></td>';
			html += '        <td class="text-right"><button type="button" data-option-row="' + option_row + '" data-toggle="tooltip" title="{{ button_option_value_add }}" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></td>';
			html += '      </tr>';
			html += '    </tfoot>';
			html += '  </table>';
			html += '</div>';

			html += '  <select id="product-option-values' + option_row + '" class="d-none">';

			for (i = 0; i < item['option_value'].length; i++) {
				html += '<option value="' + item['option_value'][i]['option_value_id'] + '">' + item['option_value'][i]['name'] + '</option>';
			}

			html += '  </select>';
			html += '</fieldset>';
		}

		$('#option').append(html);

		$('[data-toggle=\'tooltip\']').tooltip({
			container: 'body',
			html: true
		});

		$('.date').datetimepicker({
			'format': 'YYYY-MM-DD',
			'locale': '{{ datepicker }}',
			'allowInputToggle': true
		});

		$('.time').datetimepicker({
			'format': 'HH:mm',
			'locale': '{{ datepicker }}',
			'allowInputToggle': true
		});

		$('.datetime').datetimepicker({
			'format': 'YYYY-MM-DD HH:mm',
			'locale': '{{ datepicker }}',
			'allowInputToggle': true
		});

		option_row++;
	}
});
//--></script>
<script type="text/javascript"><!--
var option_value_row = {{ option_value_row }};

$('#option').on('click', '.btn-primary', function() {
	var element = this;

	if ($(element).attr('data-option-value-row')) {
		element.option_value_row = $(element).attr('data-option-value-row');
	} else {
		element.option_value_row = option_value_row;
	}

	$('.modal').remove();

	html = '<div id="modal-option" class="modal fade">';
	html += '  <div class="modal-dialog">';
	html += '    <div class="modal-content">';
	html += '      <div class="modal-header">';
	html += '        <h5 class="modal-title"><i class="fas fa-pencil-alt"></i> {{ text_option_value }}</h5> <button type="button" class="close" data-dismiss="modal">&times;</button>';
	html += '      </div>';
	html += '      <div class="modal-body">';
	html += '        <div class="form-group">';
	html += '      	   <label for="input-modal-option-value" class="col-form-label">{{ entry_option_value }}</label>';
	html += '      	   <select name="option_value_id" id="input-modal-option-value" class="form-control">';

	option_value = $('#product-option-values' + $(element).attr('data-option-row') + ' option');

	for (i = 0; i < option_value.length; i++) {
		if ($(element).attr('data-option-value-row') && $(option_value[i]).val() == $('input[name=\'product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][option_value_id]\']').val()) {
			html += '<option value="' + $(option_value[i]).val() + '" selected="selected">' + $(option_value[i]).text() + '</option>';
		} else {
			html += '<option value="' + $(option_value[i]).val() + '">' + $(option_value[i]).text() + '</option>';
		}
	}

	html += '      	   </select>';
	html += '          <input type="hidden" name="product_option_value_id" value="' + ($(element).attr('data-option-value-row') ? $('input[name=\'product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][product_option_value_id]\']').val() : '') + '"/>';
	html += '        </div>';

	html += '        <div class="form-group">';
	html += '      	   <label for="input-modal-quantity" class="col-form-label">{{ entry_quantity }}</label>';
	html += '      	   <input type="text" name="quantity" value="' + ($(element).attr('data-option-value-row') ? $('input[name=\'product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][quantity]\']').val() : '1') + '" placeholder="{{ entry_quantity }}" id="input-modal-quantity" class="form-control"/>';
	html += '        </div>';

	html += '        <div class="form-group">';
	html += '      	   <label for="input-modal-subtract" class="col-form-label">{{ entry_subtract }}</label>';
	html += '      	   <select name="subtract" id="input-modal-subtract" class="form-control">';

	if ($(element).attr('data-option-value-row') && $('input[name=\'product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][subtract]\']').val() == '1') {
		html += '        <option value="1" selected="selected">{{ text_yes }}</option>';
		html += '      	 <option value="0">{{ text_no }}</option>';
	} else {
		html += '      	 <option value="1">{{ text_yes }}</option>';
		html += '      	 <option value="0" selected="selected">{{ text_no }}</option>';
	}

	html += '      	   </select>';
	html += '        </div>';

	html += '        <div class="form-group">';
	html += '      	   <label for="input-modal-price" class="col-form-label">{{ entry_price }}</label>';
	html += '          <div class="input-group">';
	html += '            <select name="price_prefix" class="form-control col-2">';

	if ($(element).attr('data-option-value-row') && $('input[name=\'product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][price_prefix]\']').val() == '+') {
		html += '      	   <option value="+" selected="selected">+</option>';
	} else {
		html += '      	   <option value="+">+</option>';
	}

	if ($(element).attr('data-option-value-row') && $('input[name=\'product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][price_prefix]\']').val() == '-') {
		html += '      	       <option value="-" selected="selected">-</option>';
	} else {
		html += '      	       <option value="-">-</option>';
	}

	html += '      	     </select>';
	html += '      	     <input type="text" name="price" value="' + ($(element).attr('data-option-value-row') ? $('input[name=\'product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][price]\']').val() : '0') + '" placeholder="{{ entry_price }}" id="input-modal-price" class="form-control"/>';
	html += '          </div>';
	html += '        </div>';

	html += '        <div class="form-group">';
	html += '      	   <label for="input-modal-points" class="col-form-label">{{ entry_points }}</label>';
	html += '          <div class="input-group">';
	html += '      	     <select name="points_prefix" class="form-control col-2">';

	if ($(element).attr('data-option-value-row') && $('input[name=\'product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][points_prefix]\']').val() == '+') {
		html += '      	       <option value="+" selected>+</option>';
	} else {
		html += '      	       <option value="+">+</option>';
	}

	if ($(element).attr('data-option-value-row') && $('input[name=\'product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][points_prefix]\']').val() == '-') {
		html += '      	       <option value="-" selected>-</option>';
	} else {
		html += '      	       <option value="-">-</option>';
	}

	html += '      	     </select>';
	html += '      	     <input type="text" name="points" value="' + ($(element).attr('data-option-value-row') ? $('input[name=\'product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][points]\']').val() : '0') + '" placeholder="{{ entry_points }}" id="input-modal-points" class="form-control"/>';
	html += '          </div>';
	html += '        </div>';

	html += '        <div class="form-group">';
	html += '      	   <label for="input-modal-weight" class="col-form-label">{{ entry_weight }}</label>';
	html += '          <div class="input-group">';
	html += '      	     <select name="weight_prefix" class="form-control col-2">';

	if ($(element).attr('data-option-value-row') && $('input[name=\'product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][weight_prefix]\']').val() == '+') {
		html += '      	       <option value="+" selected>+</option>';
	} else {
		html += '      	       <option value="+">+</option>';
	}

	if ($(element).attr('data-option-value-row') && $('input[name=\'product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][weight_prefix]\']').val() == '-') {
		html += '      	       <option value="-" selected>-</option>';
	} else {
		html += '      	       <option value="-">-</option>';
	}

	html += '      	     </select>';
	html += '      	     <input type="text" name="weight" value="' + ($(element).attr('data-option-value-row') ? $('input[name=\'product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][weight]\']').val() : '0') + '" placeholder="{{ entry_weight }}" id="input-modal-weight" class="form-control" />';
	html += '          </div>';
	html += '        </div>';

	html += '      </div>';

	html += '      <div class="modal-footer">';
	html += '	     <button type="button" id="button-save" data-option-row="' + $(element).attr('data-option-row') + '" data-option-value-row="' + element.option_value_row + '" class="btn btn-primary">{{ button_save }}</button> <button type="button" class="btn btn-light" data-dismiss="modal">{{ button_cancel }}</button>';
	html += '      </div>';
	html += '    </div>';
	html += '  </div>';
	html += '</div>';

	$('body').append(html);

	$('#modal-option').modal('show');

	$('#modal-option #button-save').on('click', function() {
		html = '<tr id="option-value-row' + element.option_value_row + '">';
		html += '  <td class="text-left">' + $('#modal-option select[name=\'option_value_id\'] option:selected').text() + '<input type="hidden" name="product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][option_value_id]" value="' + $('#modal-option select[name=\'option_value_id\']').val() + '"/><input type="hidden" name="product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][product_option_value_id]" value="' + $('#modal-option input[name=\'product_option_value_id\']').val() + '"/></td>';
		html += '  <td class="text-right">' + $('#modal-option input[name=\'quantity\']').val() + '<input type="hidden" name="product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][quantity]" value="' + $('#modal-option input[name=\'quantity\']').val() + '"/></td>';
		html += '  <td class="text-left">' + ($('#modal-option select[name=\'subtract\'] option:selected').val() == '1' ? '{{ text_yes }}' : '{{ text_no }}') + '<input type="hidden" name="product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][subtract]" value="' + $('#modal-option select[name=\'subtract\'] option:selected').val() + '"/></td>';
		html += '  <td class="text-right">' + $('#modal-option select[name=\'price_prefix\'] option:selected').val() + $('#modal-option input[name=\'price\']').val() + '<input type="hidden" name="product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][price_prefix]" value="' + $('#modal-option select[name=\'price_prefix\'] option:selected').val() + '"/><input type="hidden" name="product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][price]" value="' + $('#modal-option input[name=\'price\']').val() + '"/></td>';
		html += '  <td class="text-right"> ' + $('#modal-option select[name=\'points_prefix\'] option:selected').val() + $('#modal-option input[name=\'points\']').val() + '<input type="hidden" name="product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][points_prefix]" value="' + $('#modal-option select[name=\'points_prefix\'] option:selected').val() + '"/><input type="hidden" name="product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][points]" value="' + $('#modal-option input[name=\'points\']').val() + '"/></td>';
		html += '  <td class="text-right">' + $('#modal-option select[name=\'weight_prefix\'] option:selected').val() + $('#modal-option input[name=\'weight\']').val() + '<input type="hidden" name="product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][weight_prefix]" value="' + $('#modal-option select[name=\'weight_prefix\'] option:selected').val() + '"/><input type="hidden" name="product_option[' + $(element).attr('data-option-row') + '][product_option_value][' + element.option_value_row + '][weight]" value="' + $('#modal-option input[name=\'weight\']').val() + '"/></td>';
		html += '  <td class="text-right"><button type="button" data-toggle="tooltip" title="{{ button_edit }}" data-option-row="' + $(element).attr('data-option-row') + '" data-option-value-row="' + element.option_value_row + '"class="btn btn-primary"><i class="fas fa-pencil-alt"></i></button> <button type="button" onclick="$(this).tooltip(\'dispose\'); $(\'#option-value-row' + element.option_value_row + '\').remove();" data-toggle="tooltip" rel="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
		html += '</tr>';

		if ($(element).attr('data-option-value-row')) {
			$('#option-value-row' + element.option_value_row).replaceWith(html);
		} else {
			$('#option-value' + $(element).attr('data-option-row')).append(html);

			option_value_row++;
		}

		$('[rel=tooltip]').tooltip();

		$('#modal-option').modal('hide');
	});
});
{% endif %}
//--></script>
<script type="text/javascript"><!--
var discount_row = {{ discount_row }};

$('#button-discount').on('click', function() {
	html = '<tr id="discount-row' + discount_row + '">';
	html += '  <td class="text-left"><select name="product_discount[' + discount_row + '][customer_group_id]" class="form-control">';
  {% for customer_group in customer_groups %}
	html += '    <option value="{{ customer_group.customer_group_id }}">{{ customer_group.name|escape('js') }}</option>';
  {% endfor %}
	html += '  </select><input type="hidden" name="product_discount[' + discount_row + '][product_discount_id]" value=""/></td>';
	html += '  <td class="text-right"><input type="text" name="product_discount[' + discount_row + '][quantity]" value="" placeholder="{{ entry_quantity }}" class="form-control" /></td>';
	html += '  <td class="text-right"><input type="text" name="product_discount[' + discount_row + '][priority]" value="" placeholder="{{ entry_priority }}" class="form-control" /></td>';
	html += '  <td class="text-right"><input type="text" name="product_discount[' + discount_row + '][price]" value="" placeholder="{{ entry_price }}" class="form-control" /></td>';
	html += '  <td class="text-left"><div class="input-group date"><input type="text" name="product_discount[' + discount_row + '][date_start]" value="" placeholder="{{ entry_date_start }}" class="form-control" /><div class="input-group-append"><div class="input-group-text"><i class="fas fa-calendar"></i></div></div></div></td>';
	html += '  <td class="text-left"><div class="input-group date"><input type="text" name="product_discount[' + discount_row + '][date_end]" value="" placeholder="{{ entry_date_end }}" class="form-control" /><div class="input-group-append"><div class="input-group-text"><i class="fas fa-calendar"></i></div></div></div></td>';
	html += '  <td class="text-right"><button type="button" onclick="$(\'#discount-row' + discount_row + '\').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fas fa-minus-circle"></i></button></td>';
	html += '</tr>';

	$('#product-discount').append(html);

	$('.date').datetimepicker({
		'format': 'YYYY-MM-DD',
		'locale': '{{ datepicker }}',
		'allowInputToggle': true
	});

	discount_row++;
});
//--></script>
<script type="text/javascript"><!--
var special_row = {{ special_row }};

$('#button-special').on('click', function() {
	html = '<tr id="special-row' + special_row + '">';
	html += '  <td class="text-left"><select name="product_special[' + special_row + '][customer_group_id]" class="form-control">';
  {% for customer_group in customer_groups %}
	html += '      <option value="{{ customer_group.customer_group_id }}">{{ customer_group.name|escape('js') }}</option>';
  {% endfor %}
	html += '  </select><input type="hidden" name="product_special[' + special_row + '][product_special_id]" value=""/></td>';
	html += '  <td class="text-right"><input type="text" name="product_special[' + special_row + '][priority]" value="" placeholder="{{ entry_priority }}" class="form-control" /></td>';
	html += '  <td class="text-right"><input type="text" name="product_special[' + special_row + '][price]" value="" placeholder="{{ entry_price }}" class="form-control" /></td>';
	html += '  <td class="text-left"><div class="input-group date"><input type="text" name="product_special[' + special_row + '][date_start]" value="" placeholder="{{ entry_date_start }}" class="form-control" /><div class="input-group-append"><div class="input-group-text"><i class="fas fa-calendar"></i></div></div></div></td>';
	html += '  <td class="text-left"><div class="input-group date"><input type="text" name="product_special[' + special_row + '][date_end]" value="" placeholder="{{ entry_date_end }}" class="form-control" /><div class="input-group-append"><div class="input-group-text"><i class="fas fa-calendar"></i></div></div></div></td>';
	html += '  <td class="text-right"><button type="button" onclick="$(\'#special-row' + special_row + '\').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fas fa-minus-circle"></i></button></td>';
	html += '</tr>';

	$('#product-special').append(html);

	$('.date').datetimepicker({
		'format': 'YYYY-MM-DD',
		'locale': '{{ datepicker }}',
		'allowInputToggle': true
	});

	special_row++;
});
//--></script>
<script type="text/javascript"><!--
var image_row = {{ image_row }};

$('#button-image').on('click', function() {
	html = '<tr id="image-row' + image_row + '">';
	html += '  <td><div class="card image">';
	html += '    <img src="{{ placeholder }}" alt="" title="" id="thumb-image' + image_row + '" data-placeholder="{{ placeholder }}" class="card-img-top"/> <input type="hidden" name="product_image[' + image_row + '][image]" value="" id="input-image' + image_row + '"/>';
	html += '    <div class="card-body">';
	html += '      <button type="button" data-toggle="image" data-target="#input-image' + image_row + '" data-thumb="#thumb-image' + image_row + '" class="btn btn-primary btn-sm btn-block"><i class="fas fa-pencil-alt"></i> {{ button_edit }}</button>';
	html += '      <button type="button" data-toggle="clear" data-target="#input-image' + image_row + '" data-thumb="#thumb-image' + image_row + '" class="btn btn-warning btn-sm btn-block"><i class="fas fa-trash-alt"></i> {{ button_clear }}</button>';
	html += '    </div>';
	html += '  </div></td>';
	html += '  <td class="text-left"><input type="text" name="product_image[' + image_row + '][sort_order]" value="0" placeholder="{{ entry_sort_order }}" class="form-control"/></td>';
	html += '  <td class="text-right"><button type="button" onclick="$(\'#image-row' + image_row + '\').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fas fa-minus-circle"></i></button></td>';
	html += '</tr>';

	$('#product-image').append(html);

	image_row++;
});
//--></script>
<script type="text/javascript"><!--
var recurring_row = {{ recurring_row }};

$('#button-recurring').on('click', function() {
	html = '<tr id="recurring-row' + recurring_row + '">';
	html += '  <td class="text-left"><select name="product_recurring[' + recurring_row + '][recurring_id]" class="form-control">';
  {% for recurring in recurrings %}
	html += '      <option value="{{ recurring.recurring_id }}">{{ recurring.name|escape('js') }}</option>';
  {% endfor %}
	html += '  </select></td>';
	html += '  <td class="text-left"><select name="product_recurring[' + recurring_row + '][customer_group_id]" class="form-control">';
  {% for customer_group in customer_groups %}
	html += '      <option value="{{ customer_group.customer_group_id }}">{{ customer_group.name|escape('js') }}</option>';
  {% endfor %}
	html += '  <select></td>';
	html += '  <td class="text-right"><button type="button" onclick="$(\'#recurring-row' + recurring_row + '\').remove()" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fas fa-minus-circle"></i></button></td>';
	html += '</tr>';

	$('#product-recurring').append(html);

	recurring_row++;
});
//--></script>
<script type="text/javascript"><!--
$('#content').on('click', 'button[id^=\'button-upload\']', function() {
	var element = this;

	$('#form-upload').remove();

	$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');

	$('#form-upload input[name=\'file\']').trigger('click');

	if (typeof timer != 'undefined') {
		clearInterval(timer);
	}

	timer = setInterval(function() {
		if ($('#form-upload input[name=\'file\']').val() != '') {
			clearInterval(timer);

			$.ajax({
				url: 'index.php?route=tool/upload/upload&user_token={{ user_token }}',
				type: 'post',
				dataType: 'json',
				data: new FormData($('#form-upload')[0]),
				cache: false,
				contentType: false,
				processData: false,
				beforeSend: function() {
					$(element).button('loading');
				},
				complete: function() {
					$(element).button('reset');
				},
				success: function(json) {
					$(element).parent().find('.invalid-tooltip').remove();

					if (json['error']) {
						$(element).parent().find('input[type=\'hidden\']').after('<div class="invalid-tooltip d-block">' + json['error'] + '</div>');
					}

					if (json['success']) {
						alert(json['success']);
					}

					if (json['code']) {
						$(element).parent().find('input[type=\'hidden\']').val(json['code']);
					}
				},
				error: function(xhr, ajaxOptions, thrownError) {
					alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
				}
			});
		}
	}, 500);
});

$('.date').datetimepicker({
	'format': 'YYYY-MM-DD',
	'locale': '{{ datepicker }}',
	'allowInputToggle': true
});

$('.time').datetimepicker({
	'format': 'HH:mm',
	'locale': '{{ datepicker }}',
	'allowInputToggle': true
});

$('.datetime').datetimepicker({
	'format': 'YYYY-MM-DD HH:mm',
	'locale': '{{ datepicker }}',
	'allowInputToggle': true
});


{% if master_id %}
// Variable products
$('input[data-toggle=\'switch\']').on('change', function(e) {
	var element = this;

	var target = $(this).attr('data-target');


	// First we need to grab the default values
	$(target).each(function() {


		// Table
		if ($(this).is('table')) {
			if (!$(element).prop('checked')) {

				$(element).html($(this).html());
			}

			console.log(this);

			//$(this).prop('disabled', !$(element).prop('checked'));
		}
	});


	// Now we need to enable or disable any fields in the targets
	$.merge($(target), $(target).find('input, textarea, select, button')).not('.custom-control-input').each(function() {
		// Text Textarea
		if ($(this).is('input[type=\'text\'], textarea')) {
			$(this).prop('readonly', !$(element).prop('checked'));
		}

		// CKEditor readonly
		if ($(this).is('[data-toggle=\'ckeditor\']')) {
			var editor = CKEDITOR.instances[$(this).attr('id')];

			if (editor.editable() == undefined) {
				editor.on('instanceReady', function() {
					this.setReadOnly(!$(element).prop('checked'));
				});
			} else {
				editor.setReadOnly(!$(element).prop('checked'));
			}
		}

		// Radio Checkbox
		if ($(this).is('input[type=\'radio\'], input[type=\'checkbox\'], div[data-toggle=\'buttons\']')) {
			if (!$(element).prop('checked')) {
				$(this).on('click', function(e) {
					return false;
				});
			} else {
				$(this).off('click');
			}
		}

		// Select
		if ($(this).is('select')) {
			if (!$(element).prop('checked')) {
				$(this).attr('readonly', 'readonly');
			} else {
				$(this).removeAttr('readonly');
			}

			$(this).find('option').not(':selected').prop('disabled', !$(element).prop('checked'));
		}

		// Button
		if ($(this).is('button')) {
			$(this).prop('disabled', !$(element).prop('checked'));
		}


	});


});

$('.custom-control-input').trigger('change');

/*
$(document).ready(function() {

$.ajax({
    url: 'index.php?route=catalog/manufacturer/autocomplete&user_token={{ user_token }}&filter_name=',
    dataType: 'json',
    success: function(json) {
        html = '<tr id="product-category' + item['value'] + '">';
        html += '  <td>' + item['label'] + '<input type="hidden" name="product_category[]" value="' + item['value'] + '"/></td>';
        html += '  <td class="text-right"><button type="button" class="btn btn-danger btn-sm"><i class="fas fa-minus-circle"></i></button></td>';
        html += '</tr>';

        $('#product-category').append(html);
    }
});
});

$('input[data-toggle=\'switch\']').on('change', function(e) {


});
*/
{% endif %}
//--></script>
<script type="text/javascript"><!--
$('#language li:first-child a').tab('show');
//--></script>
{{ footer }}